From 93ca3ae23e542570c0bb5c333df1a6df5ec59b9a Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Mon, 26 Aug 2024 13:50:26 +0200 Subject: [PATCH] E2E delete recorded video if spec passed --- alfa-client/apps/alfa-e2e/cypress.config.ts | 10 ---------- alfa-client/apps/alfa-e2e/src/support/cypress-tasks.ts | 7 +++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/alfa-client/apps/alfa-e2e/cypress.config.ts b/alfa-client/apps/alfa-e2e/cypress.config.ts index 8b9ae40a50..4b0131d939 100644 --- a/alfa-client/apps/alfa-e2e/cypress.config.ts +++ b/alfa-client/apps/alfa-e2e/cypress.config.ts @@ -10,16 +10,6 @@ export default defineConfig({ ...nxE2EPreset(__dirname), ...cypressConfig, setupNodeEvents(on, config) { - on('after:spec', (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => { - if (results && results.video) { - const failures = results.tests.some((test) => - test.attempts.some((attempt) => attempt.state === 'failed'), - ); - if (!failures) { - fs.unlinkSync(results.video); - } - } - }); return cypressEvents(on, config); }, }, diff --git a/alfa-client/apps/alfa-e2e/src/support/cypress-tasks.ts b/alfa-client/apps/alfa-e2e/src/support/cypress-tasks.ts index a82b4f7366..827b7b3d31 100644 --- a/alfa-client/apps/alfa-e2e/src/support/cypress-tasks.ts +++ b/alfa-client/apps/alfa-e2e/src/support/cypress-tasks.ts @@ -67,6 +67,13 @@ module.exports = (on: any, config: any) => { }, }); + on('after:spec', (spec: Cypress.Spec, results: CypressCommandLine.RunResult) => { + if (results && results.video && results.stats.failures === 0) { + console.log(`Delete recorded video because spec passed: ${results.video}`); + fs.unlinkSync(results.video); + } + }); + // Workaround für Angular 13 und Cypress mit Webpack 4, // Siehe https://github.com/cypress-io/cypress/issues/19066#issuecomment-1012055705 // Entfernen, sobald Cypress Webpack 5 nutzt - https://github.com/cypress-io/cypress/issues/19555 -- GitLab