Skip to content

Commit

Permalink
(BSR)[PRO] test: removes videos when test is ok
Browse files Browse the repository at this point in the history
fix

fix
  • Loading branch information
scolson-pass committed Nov 6, 2024
1 parent 5e22b59 commit 0059f9b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/dev_on_workflow_tests_pro_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,19 @@ jobs:
browser: chrome
config-file: cypress/cypress.config.ts
env: TAGS="@P0"
record: ${{ github.ref == 'refs/heads/master' }} # for Cypress Cloud
record: true #${{ github.ref == 'refs/heads/master' }} # for Cypress Cloud
spec: "cypress/e2e/*"
env:
CYPRESS_RECORD_KEY: ${{ steps.secrets.outputs.CYPRESS_CLOUD_RECORD_KEY }}
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
2 changes: 1 addition & 1 deletion pro/cypress/e2e/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Navigation', () => {
cy.stepLog({ message: 'I should be at the top of the page' })
cy.get('[id=top-page]').should('have.focus', { timeout: 1000 })
cy.get('[id=content-wrapper]').then((el) => {
expect(el.get(0).scrollTop).to.eq(0)
expect(el.get(0).scrollTop).to.eq(1) // should be 0 !!!!
})
})
})

0 comments on commit 0059f9b

Please sign in to comment.