Skip to content

Commit ddd01a5

Browse files
committed
mgr/dashboard: save video only on failure
as per https://docs.cypress.io/app/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests. This would save storage as saving entire video is useless Fixes: https://tracker.ceph.com/issues/68871 Signed-off-by: Nizamudeen A <[email protected]>
1 parent d8d7836 commit ddd01a5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/pybind/mgr/dashboard/frontend/cypress.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { defineConfig } from 'cypress';
2+
import fs from 'fs'
23

34
export default defineConfig({
45
video: true,
@@ -37,6 +38,21 @@ export default defineConfig({
3738
// We've imported your old cypress plugins here.
3839
// You may want to clean this up later by importing these.
3940
setupNodeEvents(on, config) {
41+
on(
42+
'after:spec',
43+
(_: Cypress.Spec, results: CypressCommandLine.RunResult) => {
44+
if (results && results.video) {
45+
// Do we have failures for any retry attempts?
46+
const failures = results.tests.some((test) =>
47+
test.attempts.some((attempt) => attempt.state === 'failed')
48+
)
49+
if (!failures) {
50+
// delete the video if the spec passed and no tests retried
51+
fs.unlinkSync(results.video)
52+
}
53+
}
54+
}
55+
)
4056
return require('./cypress/plugins/index.js')(on, config);
4157
},
4258
baseUrl: 'https://localhost:4200/',

0 commit comments

Comments
 (0)