Skip to content

Commit

Permalink
Clean up how Cypress tests are run (#832)
Browse files Browse the repository at this point in the history
* Remove replay and ensure that we don't send tests to Cypress Cloud for Dependabot PRs

* Fix browser references
  • Loading branch information
wpscholar authored Nov 30, 2023
1 parent cf4b06e commit d27dbee
Show file tree
Hide file tree
Showing 7 changed files with 441 additions and 831 deletions.
23 changes: 4 additions & 19 deletions .github/workflows/cypress-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,12 @@ jobs:
run: npx wp-env start --debug

- name: Run Cypress Tests
env:
RECORD_REPLAY_API_KEY: ${{ secrets.RECORD_REPLAY_API_KEY }}
if: ${{ github.repository != 'bluehost/bluehost-wordpress-plugin' || env.RECORD_REPLAY_API_KEY == '' }}
run: npx cypress run
if: ${{ github.repository != 'bluehost/bluehost-wordpress-plugin' || github.actor == 'dependabot[bot]' }}
run: npm run test:e2e -- --browser chrome

- name: Run Cypress Tests
uses: replayio/[email protected]
env:
RECORD_REPLAY_METADATA_TEST_RUN_TITLE: "php-${{ matrix.phpVersion }}, wp-${{ matrix.wpVersion }}"
RECORD_REPLAY_API_KEY: ${{ secrets.RECORD_REPLAY_API_KEY }}
if: ${{ github.repository == 'bluehost/bluehost-wordpress-plugin' && env.RECORD_REPLAY_API_KEY != '' }}
with:
api-key: ${{ secrets.RECORD_REPLAY_API_KEY }}
browser: 'replay-chromium'
command: npm run test:e2e -- --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --tag bluehost,php-${{ matrix.phpVersion }},wp-${{ matrix.wpVersion }}
upload-all: false

- name: List Replays
if: always()
shell: bash
run: npx @replayio/replay ls --json
if: ${{ github.repository == 'bluehost/bluehost-wordpress-plugin' && github.actor != 'dependabot[bot]' }}
run: npm run test:e2e -- --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --tag "bluehost,php-${{ matrix.phpVersion }},wp-${{ matrix.wpVersion }}"

- name: Store screenshots of test failures
if: ${{ failure() }}
Expand Down
26 changes: 6 additions & 20 deletions .github/workflows/cypress-tests-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,13 @@ jobs:
- name: Install WordPress
run: npx wp-env start --debug

- name: Run Cypress Beta Only Tests
env:
RECORD_REPLAY_API_KEY: ${{ secrets.RECORD_REPLAY_API_KEY }}
if: ${{ github.repository != 'bluehost/bluehost-wordpress-plugin' || env.RECORD_REPLAY_API_KEY == '' }}
run: npx cypress run
- name: Run Cypress Tests
if: ${{ github.repository != 'bluehost/bluehost-wordpress-plugin' || github.actor == 'dependabot[bot]' }}
run: npm run test:e2e -- --browser chrome

- name: Run Cypress Beta Only Tests
uses: replayio/[email protected]
env:
RECORD_REPLAY_API_KEY: ${{ secrets.RECORD_REPLAY_API_KEY }}
if: ${{ github.repository == 'bluehost/bluehost-wordpress-plugin' && env.RECORD_REPLAY_API_KEY != '' }}
with:
api-key: ${{ secrets.RECORD_REPLAY_API_KEY }}
browser: 'replay-chromium'
command: npm run test:e2e -- --record --key ${{ secrets.CYPRESS_RECORD_KEY }}
upload-all: false

- name: List Replays
if: always()
shell: bash
run: npx @replayio/replay ls --json
- name: Run Cypress Tests
if: ${{ github.repository == 'bluehost/bluehost-wordpress-plugin' && github.actor != 'dependabot[bot]' }}
run: npm run test:e2e -- --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --tag "bluehost, wp-beta"

- name: Store screenshots of test failures
if: failure()
Expand Down
22 changes: 4 additions & 18 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,12 @@ jobs:
run: npx wp-env start --debug

- name: Run Cypress Tests
env:
RECORD_REPLAY_API_KEY: ${{ secrets.RECORD_REPLAY_API_KEY }}
if: ${{ github.repository != 'bluehost/bluehost-wordpress-plugin' || env.RECORD_REPLAY_API_KEY == '' }}
run: npx cypress run
if: ${{ github.repository != 'bluehost/bluehost-wordpress-plugin' || github.actor == 'dependabot[bot]' }}
run: npm run test:e2e -- --browser chrome

- name: Run Cypress Tests
uses: replayio/[email protected]
env:
RECORD_REPLAY_API_KEY: ${{ secrets.RECORD_REPLAY_API_KEY }}
if: ${{ github.repository == 'bluehost/bluehost-wordpress-plugin' && env.RECORD_REPLAY_API_KEY != '' }}
with:
api-key: ${{ secrets.RECORD_REPLAY_API_KEY }}
browser: 'replay-chromium'
command: npm run test:e2e -- --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --tag bluehost
upload-all: false

- name: List Replays
if: always()
shell: bash
run: npx @replayio/replay ls --json
if: ${{ github.repository == 'bluehost/bluehost-wordpress-plugin' && github.actor != 'dependabot[bot]' }}
run: npm run test:e2e -- --browser chrome --record --key ${{ secrets.CYPRESS_RECORD_KEY }} --tag bluehost

- name: Store screenshots of test failures
if: failure()
Expand Down
5 changes: 0 additions & 5 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { defineConfig } = require('cypress')
const cypressReplay = require("@replayio/cypress")
const { phpVersion, core } = require('./.wp-env.json')
const wpVersion = /[^/]*$/.exec(core)[0]

Expand All @@ -18,7 +17,6 @@ module.exports = defineConfig({
screenshotsFolder: 'tests/cypress/screenshots',
video: true,
videosFolder: 'tests/cypress/videos',
videoUploadOnPasses: false,
chromeWebSecurity: false,
viewportWidth: 1024,
viewportHeight: 768,
Expand All @@ -31,9 +29,6 @@ module.exports = defineConfig({
setupNodeEvents(on, config) {
const semver = require('semver');

// Setup Replay
cypressReplay.default(on, config);

// Ensure that the base URL is always properly set.
if (config.env && config.env.baseUrl) {
config.baseUrl = config.env.baseUrl;
Expand Down
Loading

0 comments on commit d27dbee

Please sign in to comment.