I am trying to run TestCafe tests inside docker container.
I am able to run my tests with npm run testrunner
locally. Inside Docker container, I get different errors on different tries.
The errors I get are as follows:
With firefox:headless --no-sandbox --disable-dev-shm-usage
option:
...-tests | Error: Cannot establish one or more browser connections.
...-tests | 3 of 3 browser connections have not been established:
...-tests | - firefox:headless --no-sandbox --disable-dev-shm-usage
...-tests | - firefox:headless --no-sandbox --disable-dev-shm-usage
...-tests | - firefox:headless --no-sandbox --disable-dev-shm-usage
...-tests |
...-tests | Hints:
...-tests | - Increase the Browser Initialization Timeout if its value is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). The timeout determines how long TestCafe waits for browsers to be ready.
...-tests | - The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.
With chromium:headless --no-sandbox --disable-dev-shm-usage
option:
...-tests | Error: Unable to open the "chromium:headless --no-sandbox --disable-dev-shm-usage" browser due to the following error:
...-tests |
...-tests | Error: WebSocket connection closed
...-tests | at /app/node_modules/chrome-remote-interface/lib/chrome.js:94:35
...-tests | at Chrome._handleConnectionClose (/app/node_modules/chrome-remote-interface/lib/chrome.js:256:13)
...-tests | at WebSocket.<anonymous> (/app/node_modules/chrome-remote-interface/lib/chrome.js:243:22)
...-tests | at WebSocket.emit (node:events:518:28)
...-tests | at WebSocket.emit (node:domain:488:12)
...-tests | at WebSocket.emitClose (/app/node_modules/ws/lib/websocket.js:246:10)
...-tests | at Socket.socketOnClose (/app/node_modules/ws/lib/websocket.js:1148:15)
...-tests | at Socket.emit (node:events:518:28)
...-tests | at Socket.emit (node:domain:488:12)
...-tests | at TCP.<anonymous> (node:net:337:12)
...-tests | at BrowserConnection._runBrowser (/app/node_modules/testcafe/src/browser/connection/index.ts:291:32)
With chromium:headless --no-sandbox --disable-dev-shm-usage
option and const testcafe = await createTestCafe({ experimentalProxyless: true });
initialization:
...-tests | Error: Unable to open the "chromium:headless --no-sandbox --disable-dev-shm-usage" browser due to the following error:
...-tests |
...-tests | Error: socket hang up
...-tests | at Socket.socketOnEnd (node:_http_client:524:23)
...-tests | at Socket.emit (node:events:530:35)
...-tests | at Socket.emit (node:domain:488:12)
...-tests | at endReadableNT (node:internal/streams/readable:1696:12)
...-tests | at processTicksAndRejections (node:internal/process/task_queues:82:21)
...-tests | at BrowserConnection._runBrowser (/app/node_modules/testcafe/src/browser/connection/index.ts:291:32)
...-tests | at processTicksAndRejections (node:internal/process/task_queues:95:5)
package.json
{
...
"scripts": {
...
"cafe:prod:h:3": "npx testcafe 'firefox:headless --no-sandbox --disable-dev-shm-usage' src/tests/masterdata",
"testrunner": "node runner.js"
},
"dependencies": {
"@aws-sdk/client-ssm": "^3.535.0",
"aws-sdk": "^2.1582.0",
"dotenv": "^16.4.5",
"downloads-folder": "^3.0.3"
}
}
runner.js
const createTestCafe = require('testcafe');
(async function () {
const testcafe = await createTestCafe({ experimentalProxyless: true });
try {
const runner = testcafe.createRunner();
const failed = await runner
.src(['src/tests/masterdata'])
.browsers('chromium:headless --no-sandbox --disable-dev-shm-usage')
.concurrency(3)
.run();
console.log('Tests failed: ' + failed);
} finally {
await testcafe.close();
}
})();
What do I need to run tests in Docker?