Record Cypress test failures in video (#27232)

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2024-02-27 14:03:34 +01:00 committed by GitHub
parent de4edc5232
commit 4eb71c4f40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View file

@ -327,6 +327,15 @@ jobs:
name: admin-ui-server-log-${{ matrix.container }}-${{ matrix.browser }} name: admin-ui-server-log-${{ matrix.container }}-${{ matrix.browser }}
path: ~/server.log path: ~/server.log
- name: Upload Cypress videos
uses: actions/upload-artifact@v3
if: github.repository != 'keycloak/keycloak-private'
with:
name: cypress-videos-${{ matrix.container }}-${{ matrix.browser }}
path: js/apps/admin-ui/cypress/videos
if-no-files-found: ignore
retention-days: 10
check: check:
name: Status Check - Keycloak JavaScript CI name: Status Check - Keycloak JavaScript CI
if: always() if: always()

View file

@ -1,7 +1,11 @@
import { defineConfig } from "cypress"; import { defineConfig } from "cypress";
import cypressSplit from "cypress-split"; import cypressSplit from "cypress-split";
import fs from "node:fs";
const isCI = process.env.CI === "true";
export default defineConfig({ export default defineConfig({
video: isCI,
projectId: "j4yhox", projectId: "j4yhox",
chromeWebSecurity: false, chromeWebSecurity: false,
viewportWidth: 1360, viewportWidth: 1360,
@ -19,7 +23,22 @@ export default defineConfig({
slowTestThreshold: 30000, slowTestThreshold: 30000,
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}", specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
setupNodeEvents(on, config) { setupNodeEvents(on, config) {
on("after:spec", (spec, results) => {
if (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);
}
}
});
cypressSplit(on, config); cypressSplit(on, config);
return config; return config;
}, },
}, },