@@ -403,6 +403,10 @@ export default class Runtime {
403403 specifier : string ,
404404 referencingModule : VMModule ,
405405 ) => {
406+ invariant (
407+ runtimeSupportsVmModules ,
408+ 'You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/en/ecmascript-modules' ,
409+ ) ;
406410 const module = await this . resolveModule (
407411 specifier ,
408412 referencingModule . identifier ,
@@ -495,7 +499,7 @@ export default class Runtime {
495499 ) : Promise < void > {
496500 invariant (
497501 runtimeSupportsVmModules ,
498- 'You need to run with a version of node that supports ES Modules in the VM API.' ,
502+ 'You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/en/ecmascript-modules ' ,
499503 ) ;
500504
501505 const [ path , query ] = ( moduleName ?? '' ) . split ( '?' ) ;
@@ -1209,6 +1213,11 @@ export default class Runtime {
12091213 filename : scriptFilename ,
12101214 // @ts -expect-error: Experimental ESM API
12111215 importModuleDynamically : async ( specifier : string ) => {
1216+ invariant (
1217+ runtimeSupportsVmModules ,
1218+ 'You need to run with a version of node that supports ES Modules in the VM API. See https://jestjs.io/docs/en/ecmascript-modules' ,
1219+ ) ;
1220+
12121221 const context = this . _environment . getVmContext ?.( ) ;
12131222
12141223 invariant ( context , 'Test environment has been torn down' ) ;
0 commit comments