Skip to content

Commit

Permalink
refactor(percy): run pixel tests on live otp2 server
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Mar 18, 2022
1 parent 49c8400 commit fe46e6d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/percy otp2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Percy OTP2

on:
push:
branches:
- master
pull_request:

jobs:
test-build-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
# This allows us to work with the repository during the lint step
fetch-depth: 2
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Install npm packages using cache
uses: bahmutov/npm-install@v1
- name: Download OTP2 config file
run: curl $PERCY_OTP2_CONFIG_URL --output /tmp/otp2config.yml
env:
PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_OTP2_CONFIG_URL }}
- name: Take Percy Snapshots
# Move everything from latest commit back to staged
run: npx percy exec -- npx jest percy/percy.test.js --force-exit
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_OTP_CONFIG_OVERRIDE: /tmp/otp2config.yml
12 changes: 8 additions & 4 deletions percy/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ beforeAll(async () => {
])

// grab ATL har file to tmp
await execa('curl', [process.env.HAR_URL, '-s', '--output', 'mock.har'])
if (process.env.HAR_URL) {
await execa('curl', [process.env.HAR_URL, '-s', '--output', 'mock.har'])
}
} catch (error) {
console.log(error)
}
Expand All @@ -66,9 +68,11 @@ beforeAll(async () => {
}).stdout.pipe(process.stdout)

// Launch mock OTP server
execa('yarn', ['percy-har-express', '-p', '9999', 'mock.har'], {
signal: harAbortController.signal
}).stdout.pipe(process.stdout)
if (process.env.HAR_URL) {
execa('yarn', ['percy-har-express', '-p', '9999', 'mock.har'], {
signal: harAbortController.signal
}).stdout.pipe(process.stdout)
}

// Web security is disabled to allow requests to the mock OTP server
browser = await puppeteer.launch({
Expand Down

0 comments on commit fe46e6d

Please sign in to comment.