Skip to content

Commit

Permalink
Merge branch 'master' into feat/tracked-entity-input
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkrulltott authored Dec 14, 2023
2 parents 20de514 + e4d5cc8 commit ccc0796
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 @@ -55,10 +78,6 @@ module.exports = defineConfig({
viewportHeight: 800,
// 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 ccc0796

Please sign in to comment.