@@ -64,6 +64,7 @@ import {
64
64
} from './helpers' ;
65
65
66
66
const esmIsAvailable = typeof SourceTextModule === 'function' ;
67
+ const supportsDynamicImport = esmIsAvailable ;
67
68
68
69
const dataURIRegex =
69
70
/ ^ d a t a : (?< mime > t e x t \/ j a v a s c r i p t | a p p l i c a t i o n \/ j s o n | a p p l i c a t i o n \/ w a s m ) (?: ; (?< encoding > c h a r s e t = u t f - 8 | b a s e 6 4 ) ) ? , (?< code > .* ) $ / ;
@@ -580,7 +581,7 @@ export default class Runtime {
580
581
// @ts -expect-error -- exiting
581
582
return ;
582
583
}
583
- if ( this . isInsideTestCode === false ) {
584
+ if ( this . isInsideTestCode === false && ! supportsDynamicImport ) {
584
585
throw new ReferenceError (
585
586
'You are trying to `import` a file outside of the scope of the test code.' ,
586
587
) ;
@@ -742,7 +743,7 @@ export default class Runtime {
742
743
process . exitCode = 1 ;
743
744
return ;
744
745
}
745
- if ( this . isInsideTestCode === false ) {
746
+ if ( this . isInsideTestCode === false && ! supportsDynamicImport ) {
746
747
throw new ReferenceError (
747
748
'You are trying to `import` a file outside of the scope of the test code.' ,
748
749
) ;
@@ -1563,7 +1564,7 @@ export default class Runtime {
1563
1564
process . exitCode = 1 ;
1564
1565
return ;
1565
1566
}
1566
- if ( this . isInsideTestCode === false ) {
1567
+ if ( this . isInsideTestCode === false && ! supportsDynamicImport ) {
1567
1568
throw new ReferenceError (
1568
1569
'You are trying to `import` a file outside of the scope of the test code.' ,
1569
1570
) ;
@@ -2466,7 +2467,9 @@ export default class Runtime {
2466
2467
const stackTrace = formatStackTrace ( stack , this . _config , {
2467
2468
noStackTrace : false ,
2468
2469
} ) ;
2469
- const formattedMessage = `\n${ message } ${ stackTrace ? `\n${ stackTrace } ` : '' } ` ;
2470
+ const formattedMessage = `\n${ message } ${
2471
+ stackTrace ? `\n${ stackTrace } ` : ''
2472
+ } `;
2470
2473
if ( ! this . loggedReferenceErrors . has ( formattedMessage ) ) {
2471
2474
console . error ( formattedMessage ) ;
2472
2475
this . loggedReferenceErrors . add ( formattedMessage ) ;
0 commit comments