Home > front end >  Disable generation of cypress folders when running tests
Disable generation of cypress folders when running tests

Time:11-12

I'm trying to do a bunch of unit tests with Cypress. Here's the npm script that runs them:

cypress run --project tests/unit/ --headless

When I run them, it generates the typical plugin/support/videos folders, but I don't need them. Is there any flag that disables the generation of these 3 folders when running the tests?

Thanks!

CodePudding user response:

Video recording can be turned off entirely by setting video to false from within your configuration.

"videoRecording": false

https://docs.cypress.io/guides/guides/screenshots-and-videos#Videos

CodePudding user response:

Just add these generated reports to a .gitignore file in the project's root like so:

# Cypress generated files #
######################
cypress.env.json
cypress.meta.json
cypress/logs/
cypress/videos/*
cypress/screenshots/*
cypress/integration/_generated/*
cypress/data/migration/generated/*.csv
cypress/fixtures/example.json
cypress/build/*

Now, these files will never be version-controlled.

You can also disable video recording with proper configuration in your cypress.json file like so: "videoRecording": false.

You can also do it with CLI by overriding your cypress.json.

Currently, there's no way to disable the generation of those files. However, you could remove them by when launching Cypress with an npm script like so:

"clean:launch:test": "rm -rf /cypress/movies && rm -rf /cypress/screenshots && cypress run --project tests/unit/ --headless"

Then you can run it like so: npm run clean:launch:test. It should remove those folders & launch Cypress's unit tests.

I suggest just adding them to .gitignore or configuring Cypress to trash them before each run. You can read about it here.

cypress.json file:

trashAssetsBeforeRuns: true
  • Related