TestCafe docker- 无法使用 运行ner class 运行 测试
TestCafe docker- unable to run tests using runner class
我的所有测试 运行 都在一个 docker 容器中并且工作正常。由于我有一些需要并发测试的测试文件和一个不需要并发测试的文件,这就是我需要为 运行 我的测试创建一个测试 运行ner 的原因。这是我的测试 运行ner class 的样子:
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);
});
当我运行它使用命令时:
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 中现有的可用浏览器图像。请提出建议,因为我所有的测试现在都卡住了。
尝试使用无头浏览器。如果您需要 运行 使用浏览器 UI 进行测试,请在您的 运行 程序中执行此 step 以初始化内存显示服务器。
我的所有测试 运行 都在一个 docker 容器中并且工作正常。由于我有一些需要并发测试的测试文件和一个不需要并发测试的文件,这就是我需要为 运行 我的测试创建一个测试 运行ner 的原因。这是我的测试 运行ner class 的样子:
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);
});
当我运行它使用命令时:
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 中现有的可用浏览器图像。请提出建议,因为我所有的测试现在都卡住了。
尝试使用无头浏览器。如果您需要 运行 使用浏览器 UI 进行测试,请在您的 运行 程序中执行此 step 以初始化内存显示服务器。