Skip to content
Snippets Groups Projects
Unverified Commit 741ae589 authored by Uladzimir Havenchyk's avatar Uladzimir Havenchyk Committed by GitHub
Browse files

ci: enable video recordings for failing cypress tests (#46281)

parent d5601723
Branches test-flakiness
Tags
No related merge requests found
import fs from "node:fs";
import path from "node:path";
import {
......@@ -95,6 +96,21 @@ const defaultConfig = {
removeDirectory,
});
// this is an official workaround to keep recordings of the failed specs only
// 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) {
// 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);
}
}
});
/********************************************************************
** CONFIG **
********************************************************************/
......@@ -134,6 +150,9 @@ const defaultConfig = {
specPattern: "e2e/test/**/*.cy.spec.{js,ts}",
viewportHeight: 800,
viewportWidth: 1280,
// enable video recording in run mode
video: true,
videoCompression: true,
};
const mainConfig = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment