TestCafe泊坞窗-无法使用运行器类运行测试 [英] TestCafe docker- unable to run tests using runner class
问题描述
我所有的测试都在docker容器中运行,并且工作正常.由于我有一些需要并发测试的测试文件和不需要并发测试的文件,因此我需要创建一个测试运行器来运行我的测试.这是我的测试跑步者类的样子:
I have all my tests running in a docker container and it works fine. Since I have a few test files which need concurrent tests and a file which doesn't need a concurrent test that is the reason I need to create a test runner to run my tests. Here is what my test runner class looks like:
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', {
name: 'html',
output: 'resultsrunner2.html' }, {
name: 'xunit',
output: 'res2.xml',
}])
.run({
skipJsErrors: true,
quarantineMode: true,
});
return Promise.all([promise1, promise2]);
})
.then(() => {
testcafe.close();
process.exit();
})
.catch((err) => {
console.log(err);
testcafe.close();
process.exit(1);
});
当我使用命令运行它时:
when I run it using the command:
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)
我也尝试了firefox
和chromium --no-sandbox
,但是对我没有任何帮助.就我而言,我正在使用TestCafe中现有的可用浏览器图像.请提出建议,因为我的所有测试都已停滞.
I tried firefox
and chromium --no-sandbox
as well but nothing worked for me. In my case, I'm using the existing available browser image from the TestCafe. Please suggest as all my tests are stuck right now.
推荐答案
尝试使用无头浏览器.如果您需要使用浏览器用户界面运行测试,请执行以下在跑步者中前进以初始化内存中的显示服务器.
Try to use a headless browser. If you need to run tests with the browser UI, perform this step in your runner to initialize the in-memory display server.
这篇关于TestCafe泊坞窗-无法使用运行器类运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!