TestCafe与Cucumber集成-github项目超时的测试用例

Mon*_*ter 1 bdd automated-tests cucumber e2e-testing testcafe

我一直在尝试使用JavaScript框架进行自动化测试,其中之一就是testCafe。我已经能够建立一个简单的TestCafe项目并为我的应用程序运行一些测试用例。但是,现在的要求是内置一些BDD支持。我在GitHub上查找了一些testCafe-cucumber集成项目,但无法运行它们。这是我尝试过的一些方法:

1)https://github.com/rquellh/testcafe-cucumber- 我克隆了存储库,-安装了npm,-使用“ npm test”运行测试用例,-启动空白浏览器,但测试未运行。我在VS代码控制台中看到此错误:

× Before # features\support\hooks.js:46
           Error: function timed out, ensure the promise resolves within 20000 milliseconds
               at Timeout._onTimeout (C:\Users\Mo\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\node_modules\cucumber\src\user_code_runner.js:61:18)
               at ontimeout (timers.js:482:11)
               at tryOnTimeout (timers.js:317:5)
               at Timer.listOnTimeout (timers.js:277:5)



× After # features\support\hooks.js:60
       ReferenceError: testController is not defined
Run Code Online (Sandbox Code Playgroud)

然后我尝试了另一个gitHub项目,即这个项目:https : //github.com/kiwigrid/gherkin-testcafe

自述文件中的运行命令对我不起作用,甚至无法识别“ gherkin-testcafe”。

当我运行没有黄瓜的TestCafe测试用例时,我的package.json中有这一行

"scripts": {
    "test": "testcafe chrome Tests/ -e --proxy https.proxy.mycompany.com:8000"
  },
Run Code Online (Sandbox Code Playgroud)

之所以提到该代理,是因为我位于代理之后,没有该代理,浏览器将启动,但不会运行任何测试用例。我在testCafe网站上找到此修复程序

我猜(不确定)这可能也是黄瓜整合的问题。这些框架都不起作用,因为它们没有在任何地方设置代理。有人可以指出我正确的方向吗?如果需要设置代理,那么它需要在框架中的哪个位置进行操作-一个示例会有所帮助吗?

hdo*_*val 5

TestCafe / Cucumber集成依赖于以编程方式启动TestCafe运行程序。

在仓库中,搜索以下顺序:

const runner = tc.createRunner();
            return runner
                .src('./test.js')
                .screenshots('reports/screenshots/', true)
                .browsers(browser)
                .run()
                .catch(function(error) {
                    console.error(error);
                });
Run Code Online (Sandbox Code Playgroud)

或搜索以下顺序:

await runner
      .browsers(browsers)
      .specs(specs)
      .steps(steps)
      .concurrency(concurrency)
      .startApp(app, appInitDelay)
      .tags(tags)
      .run(...)
Run Code Online (Sandbox Code Playgroud)

在对象上链接useProxy方法runner(在run()方法之前执行):

const runner = tc.createRunner();
            return runner
                .src('./test.js')
                .screenshots('reports/screenshots/', true)
                .browsers(browser)
                .useProxy('username:password@proxy.mycorp.com')
                .run()
                .catch(function(error) {
                    console.error(error);
                });
Run Code Online (Sandbox Code Playgroud)