Skip to content

Commit 5c3444a

Browse files
fix(ci): allow retries for fetch test
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
1 parent 246e4da commit 5c3444a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

test/builtins/fetch.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { strictEqual, ok } from 'node:assert';
22

3+
const FETCH_URL = 'https://httpbin.org/anything';
4+
35
export const source = `
46
export async function run () {
5-
const res = await fetch('https://httpbin.org/anything');
7+
const res = await fetch('${FETCH_URL}');
68
const source = await res.json();
79
console.log(source.url);
810
}
@@ -14,7 +16,19 @@ export const source = `
1416
export const enableFeatures = ['http'];
1517

1618
export async function test(run) {
17-
const { stdout, stderr } = await run();
19+
let retries = 3;
20+
let stdout, stderr;
21+
while (retries > 0) {
22+
try {
23+
const result = await run();
24+
stdout = result.stdout;
25+
stderr = result.stderr;
26+
break;
27+
} catch (err) {
28+
console.error('failed to fetch URL', err);
29+
}
30+
retries -= 1;
31+
}
1832
strictEqual(stderr, '');
19-
strictEqual(stdout.trim(), 'https://httpbin.org/anything');
33+
strictEqual(stdout.trim(), FETCH_URL);
2034
}

0 commit comments

Comments
 (0)