Skip to content

Commit 07b62b2

Browse files
committed
impl retry for buttons
1 parent 0a5b5c5 commit 07b62b2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

e2e/script.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ const PAGES = [
123123
},
124124
];
125125

126+
async function retry(fn, retries = 1, delayMs = 1000) {
127+
for (let i = 0; i <= retries; i++) {
128+
try {
129+
return await fn();
130+
} catch (err) {
131+
if (i === retries) throw err;
132+
await new Promise((r) => setTimeout(r, delayMs));
133+
}
134+
}
135+
}
136+
126137
// Loops through each page config, performing:
127138
// - checkPath
128139
// - checkButton
@@ -133,7 +144,7 @@ async function runChecks(page) {
133144
await checkPath(page, path);
134145
await page.goto(`${BASE_URL}${path}`, { waitUntil: "networkidle" });
135146
for (const btn of buttons) {
136-
await checkButton(page, path, btn);
147+
await retry(() => checkButton(page, path, btn));
137148
}
138149
for (const lnk of links) {
139150
await checkLink(page, path, lnk);

0 commit comments

Comments
 (0)