Skip to content

Commit 8e347d1

Browse files
committed
(BSR)[PRO] test: removes videos when test is ok
fix fix (BSR)[PRO] test: fix
1 parent f3275a5 commit 8e347d1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

.github/workflows/dev_on_workflow_tests_pro_e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,12 @@ jobs:
152152
CYPRESS_PROJECT_ID: ${{ steps.secrets.outputs.CYPRESS_CLOUD_PROJECT_ID }}
153153
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154154
- name: "Move cypress videos"
155-
if: ${{ github.ref != 'refs/heads/master' }} # useless on master bc Cypress Cloud
155+
if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud
156156
run: |
157157
mkdir -p cypress/videos/${{ github.ref }}/${{ github.sha }} && \
158158
mv cypress/videos/*.mp4 cypress/videos/${{ github.ref }}/${{ github.sha }}/
159159
- name: "Archive E2E results"
160-
if: ${{ github.ref != 'refs/heads/master' }} # useless on master bc Cypress Cloud
160+
if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud
161161
uses: google-github-actions/upload-cloud-storage@v2
162162
with:
163163
path: "pro/cypress/videos"

pro/cypress/cypress.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
import { defineConfig } from 'cypress'
22
import cypressFailFast = require('cypress-fail-fast/plugin')
3+
import fs from 'fs'
34

45
// ts-unused-exports:disable-next-line
56
export default defineConfig({
67
e2e: {
78
setupNodeEvents(on, config) {
89
cypressFailFast(on, config)
10+
on(
11+
'after:spec',
12+
(spec: Cypress.Spec, results: CypressCommandLine.RunResult) => {
13+
if (results && results.video) {
14+
// Do we have failures for any retry attempts?
15+
const failures = results.tests.some((test) =>
16+
test.attempts.some((attempt) => attempt.state === 'failed')
17+
)
18+
if (!failures) {
19+
// delete the video if the spec passed and no tests retried
20+
fs.unlinkSync(results.video)
21+
}
22+
}
23+
}
24+
)
925
// Make sure to return the config object as it might have been modified by the plugin.
1026
return config
1127
},

0 commit comments

Comments
 (0)