This Image uses the Zenika's alpine-chrome Image as base and setups Codecept and Multimocha with it. You can mount your Codecept project into a container where it will get executed without additional setup.
To take advantage of the Sandbox features of Chrome and securely run any tests, you need to provide a seccomp file (chrome-seccomp.json) to the container.
You can do this by providing these additional parameters to the docker run command: --security-opt seccomp=$(pwd)/chrome-seccomp.json
Credits go to the alpine-chrome Image for providing this method.
Run your codecept project
docker run -it --rm --security-opt seccomp=$(pwd)/chrome-seccomp.json -v /path/to/your/codecept/folder:/tests ghcr.io/mt-ag/codecept-multimocha-puppeteer:latest
Run the example test:
docker run -it --rm --security-opt seccomp=$(pwd)/chrome-seccomp.json -v $(pwd)/test/sample:/tests ghcr.io/mt-ag/codecept-multimocha-puppeteer:latest
Note that you need Playwright in your Codecept config and multimocha:
exports.config = {
tests: "./*.test.js",
output: "./output",
helpers: {
Puppeteer: {
url: "http://localhost",
show: false,
},
},
mocha: {
reporterOptions: {
"codeceptjs-cli-reporter": {
stdout: "-",
options: {
verbose: false,
steps: true,
},
},
"mocha-junit-reporter": {
stdout: "./output/console.log",
options: {
mochaFile: "./output/result.xml",
},
attachments: true,
},
},
},
...
};
Build Image
docker build . -t codecept-multimocha-puppeteer
Debug:
docker run -it --rm --security-opt seccomp=$(pwd)/chrome-seccomp.json -v $(pwd)/test/sample:/tests codecept-multimocha-puppeteer:latest /bin/ash
./run_tests.sh