Home > Mobile >  Archiving reports, cypress.json file
Archiving reports, cypress.json file

Time:09-22

I want to store all new and previous reports in my directory.

Current behavior

Right now after running tests by 'npm run test' previous reports are deleted or appended (when i delete line clean reports in package.json).

Desired behavior

I want to give my directory path a dynamic name e.g with current date or number so previous ones stays where they are but i don't know if it is possible to do it inside cypres.json. Is there any solution workaround?

Code

package.json

"scripts": { "clean:reports": rmdir /S /Q cypress\reports && mkdir cypress\reports && mkdircypress\reports\mochareports",

"pretest": "npm run archive-report && npm run clean:reports",

"scripts": "cypress run --browser chrome",

"combine-reports": "mochawesome-merge ./cypress/reports/chrome/mocha/*.json > cypress/reports/chrome/mochareports/report.json",

"generate-report": "marge cypress/reports/chrome/mochareports/report.json -f report -o cypress/reports/chrome/mochareports",

"posttest-chrome": "npm run combine-reports && npm run generate-report",

"test-chrome": "npm run scripts || npm run posttest-chrome"

cypress.json

"reporter": "cypress-multi-reporters",

"reporterOptions": {

"reporterEnabled": "mochawesome",

"mochaFile": "raports/my-test-output-.xml",

"mochawesomeReporterOptions": {

"reportDir": "cypress/reports/mocha",

"quite": true,

"overwrite": false,

"html": false,

"json": true

} }

simillar: ReportDir of a mochawesome reporter option in cypress.json to point to folder created at run time named after timestamp

CodePudding user response:

A workaround: If you start the tests in some CI, then once npm run test command is finished you can add additional steps to do this for you, for bash it would be something like:

dirName="$(date  "%d-%m-%Y-%H:%M:%S")"
mkdir $dirName
mv cypress/screenshots/*.json $dirName

More details regarding the dirName here.

  • Related