Skip to content

Commit

Permalink
Add screenshot to test report
Browse files Browse the repository at this point in the history
  • Loading branch information
n313893254 committed Jul 21, 2023
1 parent 4526154 commit 844e049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions cypress/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 8 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import cookie from 'cookie';
import addContext from "mochawesome/addContext";

import { Constants } from '../constants/constants'
const constants = new Constants();
Expand Down Expand Up @@ -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);
}
});

0 comments on commit 844e049

Please sign in to comment.