File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 11import { strictEqual , ok } from 'node:assert' ;
22
3+ const FETCH_URL = 'https://httpbin.org/anything' ;
4+
35export 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 = `
1416export const enableFeatures = [ 'http' ] ;
1517
1618export 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}
You can’t perform that action at this time.
0 commit comments