From 2371bdadc978b56158f05b95bc9e18c54c1d8d7d Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Tue, 27 Feb 2024 09:28:53 +0100 Subject: [PATCH] ci: skip videos for successful tests (#25083) * ci: skip videos for successful tests Nobody will spend hours watching successful test cases. We're only interested in the failing ones, so we can save some time here. * ci: remove outdated cypress config "The videoUploadOnPasses configuration option was removed in Cypress version 13.0.0." --- cypress.config.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cypress.config.js b/cypress.config.js index 96f89b8152..475b099e9e 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,4 +1,5 @@ const { defineConfig } = require("cypress"); +const fs = require("fs"); module.exports = defineConfig({ projectId: "92odwv", @@ -7,7 +8,6 @@ module.exports = defineConfig({ defaultCommandTimeout: 20000, pageLoadTimeout: 15000, video: true, - videoUploadOnPasses: false, viewportHeight: 960, viewportWidth: 1400, retries: { @@ -18,6 +18,19 @@ module.exports = defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { + // Delete videos for specs without failing or retried tests + // https://docs.cypress.io/guides/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests + on("after:spec", (spec, results) => { + if (results && results.video) { + const failures = results.tests.some((test) => + test.attempts.some((attempt) => attempt.state === "failed") + ); + if (!failures) { + fs.unlinkSync(results.video); + } + } + }); + return require("./cypress/plugins/index.js")(on, config); }, testIsolation: false,