Skip to content

Commit

Permalink
Add retries
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Aug 21, 2023
1 parent a63722a commit 1d2cc56
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testcafe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
run: yarn build-rollup

- name: Run ${{ matrix.name }} test
run: yarn testcafe "browserstack:${{ matrix.browserstack }}"
run: node scripts/run-browserstack-with-retries.mjs --browser "browserstack:${{ matrix.browserstack }}" --retries 3
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"testcafe": "1.19.0",
"testcafe-browser-provider-browserstack": "1.14.0",
"tslib": "^2.4.0",
"typescript": "^4.7.4"
"typescript": "^4.7.4",
"yargs": "^17.7.2"
},
"lint-staged": {
"*.{ts,tsx,js,json}": "prettier --write",
Expand Down
30 changes: 30 additions & 0 deletions scripts/run-browserstack-with-retries.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import yargs from "yargs"

import {spawnSync} from "child_process"


const main = async () => {
const argv= yargs(process.argv).argv
const retries = argv.retries || 3
const browser = argv.browser
if (!browser) {
throw new Error("Missing browser argument")
}


for (let i = 0; i < retries; i++) {
console.log(`Running test ${i + 1}/${retries}`)
const result = spawnSync("yarn", ["testcafe", browser], {stdio: "inherit"})
if (result.status === 0) {
console.log("Test succeeded")
return
}
console.log("Test failed")
}
}


main().catch(e => {
console.error(e)
process.exit(1)
})
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12212,7 +12212,7 @@ yargs@^16.2.0:
y18n "^5.0.5"
yargs-parser "^20.2.2"

yargs@^17.3.1, yargs@^17.5.1:
yargs@^17.3.1, yargs@^17.5.1, yargs@^17.7.2:
version "17.7.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269"
integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==
Expand Down

0 comments on commit 1d2cc56

Please sign in to comment.