@@ -25,14 +25,33 @@ describe("destination()", () => {
2525 let specs : ExpectedResults ;
2626
2727 beforeAll ( async ( ) => {
28+ // Retry logic for fetching manifests from npm registry
29+ const fetchWithRetry = async < T > (
30+ fn : ( ) => Promise < T > ,
31+ retries = 3 ,
32+ delay = 1000 ,
33+ ) : Promise < T > => {
34+ for ( let i = 0 ; i < retries ; i ++ ) {
35+ try {
36+ return await fn ( ) ;
37+ } catch ( error ) {
38+ if ( i === retries - 1 ) throw error ;
39+ await new Promise ( ( resolve ) => setTimeout ( resolve , delay ) ) ;
40+ }
41+ }
42+ throw new Error ( "Failed after retries" ) ;
43+ } ;
44+
2845 const manifests : ExpectedResults <
2946 pacote . AbbreviatedManifest & pacote . ManifestResult
3047 > = Object . freeze ( {
31- "^2.1" : await pacote . manifest ( `chalk@^2.1` ) ,
32- "~2.1" : await pacote . manifest ( `chalk@~2.1` ) ,
33- latest : await pacote . manifest ( "chalk" ) ,
34- "^3.0.0-beta" : await pacote . manifest ( "chalk@^3.0.0-beta" ) ,
35- next : await pacote . manifest ( "chalk@next" ) ,
48+ "^2.1" : await fetchWithRetry ( ( ) => pacote . manifest ( `chalk@^2.1` ) ) ,
49+ "~2.1" : await fetchWithRetry ( ( ) => pacote . manifest ( `chalk@~2.1` ) ) ,
50+ latest : await fetchWithRetry ( ( ) => pacote . manifest ( "chalk" ) ) ,
51+ "^3.0.0-beta" : await fetchWithRetry ( ( ) =>
52+ pacote . manifest ( "chalk@^3.0.0-beta" ) ,
53+ ) ,
54+ next : await fetchWithRetry ( ( ) => pacote . manifest ( "chalk@next" ) ) ,
3655 } ) ;
3756
3857 const versions : ExpectedResults = Object . freeze ( {
0 commit comments