Skip to content

Commit

Permalink
chore: prevent test suite from crashing when failing to delete a video
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric committed Nov 21, 2023
1 parent a50e3d8 commit 3d46b49
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ async function setupNodeEvents(on, config) {

// Delete videos for passing tests
on('after:spec', (spec, results) => {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === 'failed')
)
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video)
try {
if (results && results.video) {
// Do we have failures for any retry attempts?
const failures = results.tests.some((test) =>
test.attempts.some((attempt) => attempt.state === 'failed')
)
if (!failures) {
// delete the video if the spec passed and no tests retried
fs.unlinkSync(results.video)
}
}
} catch (error) {
if (error.code === 'ENOENT') {
console.log('Video already deleted')
} else {
throw error
}
}
})
Expand Down

0 comments on commit 3d46b49

Please sign in to comment.