diff --git a/cypress/cypress.config.ts b/cypress/cypress.config.ts index 7384659dc..8fd7c0363 100644 --- a/cypress/cypress.config.ts +++ b/cypress/cypress.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ requestTimeout: 240000, responseTimeout: 240000, chromeWebSecurity: false, + screenshotsFolder: 'cypress/results/mochawesome-report/assets', env: { NODE_ENV: 'production', username: 'admin', diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 5158a2a4d..15233ce09 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -1,4 +1,5 @@ import cookie from 'cookie'; +import addContext from "mochawesome/addContext"; import { Constants } from '../constants/constants' const constants = new Constants(); @@ -57,3 +58,10 @@ Cypress.Commands.overwrite('visit', (originalFn, url = '', options) => { Cypress.on('uncaught:exception', (err, runable) => { return false; }) + +Cypress.on("test:after:run", (test, runnable) => { + if (test.state === "failed") { + const screenshot =`assets/${Cypress.spec.name}/${runnable.parent.title} -- ${test.title} (failed).png`; + addContext({ test }, screenshot); + } +});