Skip to content

Commit 5cad671

Browse files
committed
Retry flaky tests
1 parent 11270d2 commit 5cad671

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

scripts/run-e2e.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { existsSync, globSync } from 'node:fs';
44
import { basename, dirname, join } from 'node:path';
55

66
const args = process.argv.slice(2).join(' ');
7+
const MAX_ATTEMPTS = 2;
78

89
// Find all spec files that have a blueprint.json in the same directory
910
const projects = globSync('**/*.spec.ts', { ignore: ['node_modules/**'] })
@@ -16,14 +17,21 @@ console.log(
1617

1718
let failed = false;
1819
for (const project of projects) {
19-
console.log(`\n▶ Running: ${project}`);
20-
try {
21-
execSync(
22-
`RUN_PROJECT="${project}" npx playwright test --project="${project}" ${args}`,
23-
{ stdio: 'inherit' },
24-
);
25-
} catch {
26-
failed = true;
20+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
21+
if (attempt > 1)
22+
console.log(
23+
`\n↻ Retrying: ${project} (attempt ${attempt}/${MAX_ATTEMPTS})`,
24+
);
25+
else console.log(`\n▶ Running: ${project}`);
26+
try {
27+
execSync(
28+
`RUN_PROJECT="${project}" npx playwright test --project="${project}" ${args}`,
29+
{ stdio: 'inherit' },
30+
);
31+
break;
32+
} catch {
33+
if (attempt === MAX_ATTEMPTS) failed = true;
34+
}
2735
}
2836
}
2937

0 commit comments

Comments
 (0)