Skip to content

Commit

Permalink
[Cypress] Fix screenshot can't see on multi level dir
Browse files Browse the repository at this point in the history
  • Loading branch information
n313893254 committed Jul 25, 2023
1 parent 6a3ee28 commit 1c7f857
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ Cypress.on('uncaught:exception', (err, runable) => {
})

Cypress.on("test:after:run", (test, runnable) => {
if (test.state === "failed") {
const screenshot =`assets/${Cypress.spec.name}/${runnable.parent.title} -- ${test.title} (failed).png`;
if (test.state === "failed") {
const dir = Cypress.spec.relative
const specDir = dir.split('/').slice(1, -1).join('/')
const screenshot =`assets/${specDir}/${Cypress.spec.name}/${runnable.parent.title} -- ${test.title} (failed).png`;

addContext({ test }, screenshot);
}
});

0 comments on commit 1c7f857

Please sign in to comment.