I am trying to run TestCafe tests inside a docker container.
Tests are working as excepted with runner or cli locally without container. When I try to run inside docker container, this error appears:
<code>ERROR Cannot find the browser. "/bin/sh" is neither a known browser alias, nor a path to an executable file.</code><code>ERROR Cannot find the browser. "/bin/sh" is neither a known browser alias, nor a path to an executable file. </code>ERROR Cannot find the browser. "/bin/sh" is neither a known browser alias, nor a path to an executable file.
I am using testcafe/testcafe image as a starter in container and installing other packages with npm. As far as I read from docs, testcafe image comes with chrome. Dockerfile:
FROM testcafe/testcafe
USER root
WORKDIR /app
COPY package*.json .
RUN npm install --force --legacy-peer-deps --progress=false
CMD npm run testrunner # this is a command that i define in package.json
package.json
{
...
"main": "index.js",
"scripts": {
"cafe:prod:h:3": "npx testcafe 'chrome:headless' --concurrency 3 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",
"testcafe": "^3.5.0",
"testcafe-browser-tools": "^2.0.26"
}
}
runner.js
const createTestCafe = require('testcafe');
(async function () {
const testcafe = await createTestCafe();
try {
const runner = testcafe.createRunner();
const failed = await runner.src(['src/tests/masterdata']).browsers('chrome:headless').concurrency(3).run();
console.log('Tests failed: ' + failed);
} finally {
await testcafe.close();
}
})();
I am not referring /bin/sh anywhere in my code. Why testcafe try to use docker from this path? How can I run runner.js inside of the container?