Skip to content

Commit

Permalink
chore: video changes from dhis2/line-listing-app#472
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott committed Dec 13, 2023
1 parent b4976f6 commit e1335c6
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const fs = require('fs')
const { chromeAllowXSiteCookies } = require('@dhis2/cypress-plugins')
const { defineConfig } = require('cypress')
const {
Expand All @@ -8,6 +9,28 @@ async function setupNodeEvents(on, config) {
chromeAllowXSiteCookies(on, config)
excludeByVersionTags(on, config)

// Delete videos for passing tests
on('after:spec', (spec, results) => {
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
}
}
})

if (!config.env.dhis2InstanceVersion) {
throw new Error(
'dhis2InstanceVersion is missing. Check the README for more information.'
Expand Down Expand Up @@ -59,10 +82,6 @@ module.exports = defineConfig({
testIsolation: false,
// Record video
video: true,
/* Only compress and upload videos for failures.
* This will save execution time and reduce the risk
* out-of-memory issues on the CI machine */
videoUploadOnPasses: false,
// Enabled to reduce the risk of out-of-memory issues
experimentalMemoryManagement: true,
// Set to a low number to reduce the risk of out-of-memory issues
Expand Down

0 comments on commit e1335c6

Please sign in to comment.