import { defineConfig } from 'cypress';
+import fs from 'fs'
export default defineConfig({
video: true,
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
+ on(
+ 'after:spec',
+ (_: Cypress.Spec, results: CypressCommandLine.RunResult) => {
+ 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)
+ }
+ }
+ }
+ )
return require('./cypress/plugins/index.js')(on, config);
},
baseUrl: 'https://localhost:4200/',