Kusuma Saddala
Kusuma Saddala

Reputation: 1

How to delete reports folder before every run in cypress?

I am storing my cucumber html report under cucumber-html-reports folder and json files are storing under cucumber-json folder. Now I want delete/empty these two folders. I need a plug in to achieve this.

Upvotes: 0

Views: 4106

Answers (1)

DJSDev
DJSDev

Reputation: 993

The correct way to do this is to add an npm script to clean up the report folder and execute it before the test run. Cypress has an example npm script on their website for this. https://docs.cypress.io/guides/tooling/reporters#Command-line-3

Usually, the CI/CD pipeline would run the clean up script before the test run kicks off. Alternatively, you could add a little bit of code to your plugins file to exec the npm script before the test run as well.

One sort of hacky option, there is a trashAssetsBeforeRuns option in the Cypress config (set to true by default). It's used to clean up the downloads, videos, and screenshots folders before a test run. If you map your reporter results to one of these directories that might work, although I can't guarantee success with it since I haven't done that.

Upvotes: 1

Related Questions