@@ -410,8 +410,17 @@ export async function downloadPackage(
410
410
411
411
// Skip actual downloads in test environment unless explicitly allowed
412
412
// Note: Tests use mock fetch, so this only blocks real network calls
413
- if ( process . env . NODE_ENV === 'test' && process . env . LAUNCHPAD_ALLOW_NETWORK !== '1' && ! globalThis . fetch . toString ( ) . includes ( 'mockFetch' ) ) {
414
- throw new Error ( 'Network calls disabled in test environment' )
413
+ if ( process . env . NODE_ENV === 'test' && process . env . LAUNCHPAD_ALLOW_NETWORK !== '1' ) {
414
+ // Check if fetch is mocked by looking for our mock marker or function name
415
+ const fetchStr = globalThis . fetch . toString ( )
416
+ const isMocked = fetchStr . includes ( 'mockFetch' )
417
+ || fetchStr . includes ( 'Mock response' )
418
+ || fetchStr . includes ( 'testing.org' )
419
+ || ( globalThis . fetch as any ) . __isMocked === true
420
+
421
+ if ( ! isMocked ) {
422
+ throw new Error ( 'Network calls disabled in test environment' )
423
+ }
415
424
}
416
425
417
426
const response = await fetch ( url , {
@@ -672,7 +681,13 @@ export async function downloadPackage(
672
681
}
673
682
674
683
// Check if we're in test mode with mock data or if the file is not a valid archive
675
- const isMockData = process . env . NODE_ENV === 'test' && globalThis . fetch . toString ( ) . includes ( 'mockFetch' )
684
+ const fetchStr = globalThis . fetch . toString ( )
685
+ const isMockData = process . env . NODE_ENV === 'test' && (
686
+ fetchStr . includes ( 'mockFetch' )
687
+ || fetchStr . includes ( 'Mock response' )
688
+ || fetchStr . includes ( 'testing.org' )
689
+ || ( globalThis . fetch as any ) . __isMocked === true
690
+ )
676
691
677
692
// Check if the archive file is valid by reading the first few bytes
678
693
let isValidArchive = false
0 commit comments