0

I am running Cypress on a Windows machine.

I am using this command (included in the package.json file) to remove the cypress/reports folder before the start of each test run:

"clean:reports": "IF EXIST 'cypress\\reports'(rmdir /Q /S cypress\\reports) && mkdir cypress\\reports\\ && mkdir cypress\\reports\\mocha\\ && mkdir cypress\\reports\\mochareports\\"

Upon analysis, I've seen that the cypress/reports folder which stores the test report folder does not get deleted even after the above mentioned script executes.

Am I using the correct command? What command should I use to ensure that the system checks for the cypress/reports folder to be present, and if yes deletes it successfully?

4
  • I believe rimraf is cross-platform, why not use something like that?
    – jonrsharpe
    Apr 25, 2020 at 15:36
  • @srini: can't you just leave out the check for existence? The rmdir command seems ok (docs.microsoft.com/en-us/windows-server/administration/…), I use it in the same way, but I do not have the if statement there. I mean why checking for existence where there's no else statement then.
    – pavelsaman
    Apr 25, 2020 at 17:41
  • Did the answer help
    – PDHide
    Apr 27, 2020 at 15:21
  • 1
    @PDHide Yes it did. Thanks very much. pavelsaman , I agree. The If condition saves the need for manually checking if the reports folder exists or not. But that is just a one time action.
    – srini
    May 12, 2020 at 8:13

1 Answer 1

1

Just wrap if exists with bracket:

I also made some cosmetic changes, please use below script

"clean:reports":"(if exist cypress\\reports (rmdir /Q /S cypress\\reports)) && mkdir cypress\\reports && mkdir cypress\\reports\\mocha  &&  mkdir cypress\\reports\\mochareports"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.