【发布时间】:2022-01-12 01:41:08
【问题描述】:
我只是不明白,为什么 testcafe 在我的情况下运行这个测试两次:
MainApp.ts:
const getUrl = ClientFunction(() => window.location.href);
class MainApp {
async login(url:string) {
await t.expect(getUrl()).eql(url);
}}
export default new MainApp();
Test.ts:
import MailosaurClient from "mailosaur";
import { Selector, t } from "testcafe";
import MainApp from "./MainApp";
const testUrl = `https://www.google.com/`;
fixture("fixture")
.page("https://www.google.com/")
.beforeEach(async (t) => {
console.log("test");
})
.disablePageCaching("fixture");
test("Test", async (t) => {
console.log("Starting test");
await MainApp.login(
testUrl
);
【问题讨论】:
-
我运行了你的测试,它按预期工作。因此,您的测试代码中没有错误。可能错误在于您运行测试的方式(在终端命令或运行程序文件中)。
-
@AlexKamaev 谢谢你的帮助,你能分享一下你的 testcafe runner 设置吗?
-
@AlexKamaev 你说它按预期工作。那么,它只为您运行一次吗?
-
是的,它只为我运行一次。但是,我在没有运行程序文件且仅使用终端命令的情况下运行测试:
testcafe chrome test.ts。请分享您的跑步者档案。我会尝试在我这边重现这个问题。
标签: typescript testing automated-tests e2e-testing testcafe