@@ -326,6 +326,7 @@ const describeCases = config => {
326326
327327 const requireCache = Object . create ( null ) ;
328328 const esmCache = new Map ( ) ;
329+ const esmIdentifier = `${ category . name } -${ testName } -${ i } ` ;
329330 // eslint-disable-next-line no-loop-func
330331 const _require = (
331332 currentDirectory ,
@@ -336,7 +337,7 @@ const describeCases = config => {
336337 ) => {
337338 if ( testConfig === undefined ) {
338339 throw new Error (
339- `_require(${ module } ) called after all tests have completed`
340+ `_require(${ module } ) called after all tests from ${ category . name } ${ testName } have completed`
340341 ) ;
341342 }
342343 if ( Array . isArray ( module ) || / ^ \. \. ? \/ / . test ( module ) ) {
@@ -382,6 +383,7 @@ const describeCases = config => {
382383 let runInNewContext = false ;
383384
384385 const moduleScope = {
386+ console : console ,
385387 it : _it ,
386388 beforeEach : _beforeEach ,
387389 afterEach : _afterEach ,
@@ -420,8 +422,8 @@ const describeCases = config => {
420422 let esm = esmCache . get ( p ) ;
421423 if ( ! esm ) {
422424 esm = new vm . SourceTextModule ( content , {
423- identifier : p ,
424- url : pathToFileURL ( p ) . href ,
425+ identifier : esmIdentifier + "-" + p ,
426+ url : pathToFileURL ( p ) . href + "?" + esmIdentifier ,
425427 context :
426428 ( parentModule && parentModule . context ) ||
427429 vm . createContext ( moduleScope , {
@@ -453,8 +455,11 @@ const describeCases = config => {
453455 return await asModule (
454456 await _require (
455457 path . dirname (
456- referencingModule . identifier ||
457- fileURLToPath ( referencingModule . url )
458+ referencingModule . identifier
459+ ? referencingModule . identifier . slice (
460+ esmIdentifier . length + 1
461+ )
462+ : fileURLToPath ( referencingModule . url )
458463 ) ,
459464 options ,
460465 specifier ,
0 commit comments