Created
December 18, 2019 08:32
-
-
Save przemuh/3b8610d3aef29f0bd8b01ee3f2b4618a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cypress.on('test:after:run', (test, runnable) => { | |
if (test.state === 'failed') { | |
let item = runnable | |
const nameParts = [runnable.title] | |
// Iterate through all parents and grab the titles | |
while (item.parent) { | |
nameParts.unshift(item.parent.title) | |
item = item.parent | |
} | |
const fullTestName = nameParts | |
.filter(Boolean) | |
.join(' -- ') // this is how cypress joins the test title fragments | |
const imageUrl = `screenshots/${ | |
Cypress.spec.name | |
}/${fullTestName} (failed).png` | |
addContext({ test }, imageUrl) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment