【问题标题】:Why testcafe runs tests twice?为什么 testcafe 运行两次测试?
【发布时间】: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


【解决方案1】:

您的代码运行良好,没有运行两次,只需更新节点并安装 testcafe 和

输入npx testcafe <browser> <path>

【讨论】:

    猜你喜欢
    • 2017-04-20
    • 2012-09-12
    • 2015-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    • 2023-03-28
    相关资源
    最近更新 更多