Skip to content

Commit

Permalink
refactor(percy): set HAR download dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
miles-grant-ibigroup committed Mar 18, 2022
1 parent 2869ac2 commit da35f94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/percy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ jobs:
run: npx percy exec -- npx jest percy/percy.test.js --force-exit
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
HAR_URL: ${{ secrets.PERCY_HAR_URL }}
17 changes: 8 additions & 9 deletions percy/percy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ jest.setTimeout(600000)
const PERCY_EXTRA_WAIT = 5000
const percySnapshotWithWait = async (page, name, enableJavaScript) => {
await page.waitForTimeout(PERCY_EXTRA_WAIT)
await percySnapshot(page, name, { enableJavaScript })

const namePrefix = process.env.PERCY_OTP_CONFIG_OVERRIDE || 'Mock OTP1 Server'
await percySnapshot(page, `${namePrefix} - ${name}`, { enableJavaScript })
}

let browser
Expand All @@ -43,19 +45,16 @@ beforeAll(async () => {
try {
// Build OTP-RR main.js using new config file
await execa('env', [
`YAML_CONFIG=${OTP_RR_TEST_CONFIG_PATH}`,
`YAML_CONFIG=${
process.env.PERCY_OTP_CONFIG_OVERRIDE || OTP_RR_TEST_CONFIG_PATH
}`,
`JS_CONFIG=${OTP_RR_TEST_JS_CONFIG_PATH}`,
'yarn',
'build'
])

// grab ATL har file to tmp
await execa('curl', [
'https://otp-repo.s3.amazonaws.com/ATL-fix_03-09-2022-14-40-46_03-10-2022-09-08-49.har',
'-s',
'--output',
'ATL.har'
])
await execa('curl', [process.env.HAR_URL, '-s', '--output', 'mock.har'])
} catch (error) {
console.log(error)
}
Expand All @@ -67,7 +66,7 @@ beforeAll(async () => {
}).stdout.pipe(process.stdout)

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

Expand Down

0 comments on commit da35f94

Please sign in to comment.