I had same problem on windows with "rm" command and "mkdir", there was no way to make it work, so instead I made a small script to handle this.
Add this js script to your "cypress" folder (create a new js file, call it whatever you want):
// Small script to make sure we always clean the report directory before running "npm run test" const fs = require("fs"); const reports = './cypress/reports'; const mocha = 'mocha' const mochareports = "mochareports" let createReportDir = (dir1,dir2) => { fs.mkdirSync(`${dir1}/${dir2}`, { recursive: true }) console.log(`Created directory: ${dir1}/${dir2}.`); } // check if directory exists if (fs.existsSync(reports)) { fs.rm(reports, { recursive: true }, (err) => { if (err) { throw err; } console.log(`Cleaning ${reports} directory.`); createReportDir(reports,mocha) createReportDir(reports,mochareports) }); } else { createReportDir(reports,mocha) createReportDir(reports,mochareports) }
`
Then call it in your package.json
"scripts": { "clean:reports": "node ./cypress/cypress-report-clean.js" }
``
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I had same problem on windows with "rm" command and "mkdir", there was no way to make it work, so instead I made a small script to handle this.
Add this js script to your "cypress" folder (create a new js file, call it whatever you want):
`
Then call it in your package.json
`
``