Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(BSR)[PRO] test: removes videos when test is ok #14941

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/dev_on_workflow_tests_pro_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ jobs:
CYPRESS_PROJECT_ID: ${{ steps.secrets.outputs.CYPRESS_CLOUD_PROJECT_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Move cypress videos"
if: ${{ github.ref != 'refs/heads/master' }} # useless on master bc Cypress Cloud
if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud
run: |
mkdir -p cypress/videos/${{ github.ref }}/${{ github.sha }} && \
mv cypress/videos/*.mp4 cypress/videos/${{ github.ref }}/${{ github.sha }}/
- name: "Archive E2E results"
if: ${{ github.ref != 'refs/heads/master' }} # useless on master bc Cypress Cloud
if: always() && failure() && github.ref != 'refs/heads/master' # useless on master bc Cypress Cloud
uses: google-github-actions/upload-cloud-storage@v2
with:
path: "pro/cypress/videos"
Expand Down
16 changes: 16 additions & 0 deletions pro/cypress/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
import { defineConfig } from 'cypress'
import cypressFailFast = require('cypress-fail-fast/plugin')
import fs from 'fs'

// ts-unused-exports:disable-next-line
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
cypressFailFast(on, config)
on(
'after:spec',
(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)
}
}
}
)
// Make sure to return the config object as it might have been modified by the plugin.
return config
},
Expand Down
Loading