Cypress provides a manual for installing and configuring multiple reporters: https://docs.cypress.io/guides/tooling/reporters#Merging-reports-across-spec-files
My goal is to make it work in a Docker container and provide the results to the host machine. What was done for this aim:
Dockerfile:
FROM cypress/base:14.17.0 RUN mkdir /cypress-docker WORKDIR /cypress-docker COPY . /cypress-docker RUN npm install --save-dev cypress RUN $(npm bin)/cypress verify RUN ["npm", "run", "cypress:e2e"]
reporter-config.json:
{ "reporterEnabled": "mocha-junit-reporter, mochawesome", "mochaJunitReporterReporterOptions": { "mochaFile": "cypress/results/junit/results-[hash].xml" }, "reporterOptions": { "reportDir": "cypress/results/mochawesome", "overwrite": false, "html": false, "json": true } }
docker-compose.yml:
version: '3.7' services: cypress_test: image: cypress_compose build: context: . dockerfile: ./Dockerfile volumes: - ./dockerReports:/cypress-docker/cypress/results - ./dockerReports:/cypress-docker/mochawesome-report
package.json:
{ "name": "cypress-docker", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "delete:reports": "rimraf cypress/results && mkdirp cypress/results", "prereport": "npm run delete:reports", "mochawesome:merge": "npx mochawesome-merge \"cypress/results/mochawesome/*.json\" > mochawesome.json && npx marge mochawesome.json", "junit:merge": "npx junit-merge -d cypress/results/junit -o cypress/results/junit/result.xml", "cypress:run": "npm run prereport && npx cypress run", "cypress:e2e": "npm run cypress:run && npm run junit:merge && npm run mochawesome:merge" }, "author": "", "license": "ISC", "devDependencies": { "cypress": "^8.2.0", "cypress-multi-reporters": "^1.5.0", "junit-merge": "^2.0.0", "mocha": "^7.8.1", "mocha-junit-reporter": "^2.0.0", "mochawesome": "^6.2.2", "mochawesome-merge": "^4.2.0", "mochawesome-report-generator": "^5.2.0" } }
So, I hope to have a directory dockerReports
containing merged JUnit and Mochawesome reports on the host machine after running docker-compose up
command. And this directory does appear but it is empty. What is the reason?