message: chore: add invariant on ESM support in dynamic import
diff: @@ -403,6 +403,10 @@ export default class Runtime {
  specifier: string,
  referencingModule: VMModule,
  ) => {
  + invariant(
  + runtimeSupportsVmModules,
  + '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',
  + );
  const module = await this.resolveModule(
  specifier,
  referencingModule.identifier,
  @@ -495,7 +499,7 @@ export default class Runtime {
  ): Promise<void> {
  invariant(
  runtimeSupportsVmModules,
  - 'You need to run with a version of node that supports ES Modules in the VM API.',
  + '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',
  );
  const [path, query] = (moduleName ?? '').split('?');
  @@ -1209,6 +1213,11 @@ export default class Runtime {
  filename: scriptFilename,
  // @ts-expect-error: Experimental ESM API
  importModuleDynamically: async (specifier: string) => {
  + invariant(
  + runtimeSupportsVmModules,
  + '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',
  + );
  +
  const context = this._environment.getVmContext?.();
  invariant(context, 'Test environment has been torn down');
  