TestCafe泊坞窗-无法使用运行器类运行测试

我所有的测试都在docker容器中运行,并且工作正常。由于我有一些需要并发测试的测试文件和一个不需要并发测试的文件,因此我需要创建一个测试运行器来运行我的测试。这是我的测试跑步者类的样子:

const createTestCafe = require('testcafe');

let testcafe = null;

createTestCafe('localhost',1337,1338)
  .then((tc) => {
    testcafe = tc;
    const runner1 = testcafe.createRunner();
    const runner2 = testcafe.createRunner();

    const promise1 = runner1
      .src(['/tests/uitests/**/conctests/accounttest.js','/tests/uitests/**/conctests/dashtest.js'])
      .browsers('chromium')
      .screenshots({ takeonFails: true })
      .reporter(['spec',{
        name: 'html',output: 'resultsrunner1.html' },{
        name: 'xunit',output: 'res1.xml',}])
      .concurrency(3)
      .run({
        skipJsErrors: true,quarantineMode: true,});

    const promise2 = runner2
      .src('/tests/uitests/**/conctests/roletest.js')
      .browsers('chromium')
      .screenshots({ takeonFails: true })
      .reporter(['spec',output: 'resultsrunner2.html' },output: 'res2.xml',}])
      .run({
        skipJsErrors: true,});

    return Promise.all([promise1,promise2]);
  })
  .then(() => {
    testcafe.close();
    process.exit();
  })
  .catch((err) => {
    console.log(err);
    testcafe.close();
    process.exit(1);
  });

当我使用命令运行它时:

docker run --net=host -v `pwd`:/tests -it --entrypoint node testcafe /tests/testrunner.js

我收到此错误:

Error: Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure.
at /tests/node_modules/testcafe/src/runner/browser-set.js:84:30
at Generator.next (<anonymous>)
at step (/tests/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /tests/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at new Promise (<anonymous>)
at new F (/tests/node_modules/core-js/library/modules/_export.js:36:28)
at /tests/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
at BrowserSet._waitConnectionsOpened (/tests/node_modules/testcafe/src/runner/browser-set.js:77:37)
at _waitConnectionsOpened (/tests/node_modules/testcafe/src/runner/browser-set.js:107:35)
at invokeCallback (/tests/node_modules/pinkie/index.js:60:12)
at Array.forEach (<anonymous>)
at publish (/tests/node_modules/pinkie/index.js:147:32)
at Array.publishFulfillment (/tests/node_modules/pinkie/index.js:152:2)
at Immediate.asyncFlush (/tests/node_modules/pinkie/index.js:17:19)
at runCallback (timers.js:706:11)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)

我也尝试过firefoxchromium --no-sandbox,但对我没有任何帮助。就我而言,我正在使用TestCafe中现有的浏览器图像。请提出建议,因为我的所有测试都已停滞。

cgb114 回答:TestCafe泊坞窗-无法使用运行器类运行测试

尝试使用无头浏览器。如果您需要使用浏览器用户界面运行测试,请在运行程序中执行此step以初始化内存中的显示服务器。

本文链接:https://www.f2er.com/3141618.html

大家都在问