Search code examples
automationcypressscreenshot

Cypress screenshotOnRunFailure not working


According to Cypress documentation, Screenshots are automatic upon run failure. This doesn't seem to be happening, however screenshots are recording in my file when I use cy.screenshot() directly in a test. I do not want to have to add this to every test.

My screenshot path is \cypress\screenshots I am using npm run cypress to open Cypress and under "configuration" I have screenshotOnRunFailure:true

Any ideas? TIA


Solution

  • What do you have in package.json under

    "scripts": { "cypress": "?" },

    "npm run cypress" (which runs your script called "cypress" from "scripts" section in package.json) is different from "cypress run" (which runs Cypress tests. By default works for creating screenshots when tests fail, with no need of writing lines: "screenshotOnRunFailure" and "screenshotsFolder" in cypress.json ).