cannot disable cypress screenshots

Viewed 3237

I am trying to disable cypress screenshots, I have this in my cypress.json:

{
  "pluginsFile": "cypress/plugins/index.js",
  "supportFile": "cypress/support/index.ts",
  "video": false,
  "screenshotOnRunFailure": false
}

But the screenshots are still happening.

3 Answers

You must set this option with Cypress.Screenshot.defaults().

In your cypress/support/index.js file add

Cypress.Screenshot.defaults({
  screenshotOnRunFailure: false
})

To disable through the command line the creation of video and screenshots, you can do the following:

cypress run --config video=false,screenshotOnRunFailure=false

If you don't want to go the route of adding things to cypress/support/index.js a solution to this could be to have multiple cypress.json config files. For example: one config file that allows screenshots (ie. "screenshotOnRunFailure": true) called allowScreenshotsConfig.json, and one that doesn't (ie. "screenshotOnRunFailure": false), called disallowScreenshotsConfig.json

Then all you will need to is target a specific config file when you run Cypress, using something like cypress open --config-file tests/allowScreenshotsConfig.json

Related