You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Darwin Nikitas-Air.lan 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64
Subsystem
test_runner
What steps will reproduce the bug?
// Run with and without --experimental-test-module-mocksimport{writeFile}from'node:fs/promises'import{mock}from'node:test'awaitwriteFile('./test-2.js',"export default 42")try{if(mock.module)mock.module('Whatever, this is not significant',{namedExports: {}})}catch{}const{default: x}=awaitimport('./test-2')console.log(`Found x: ${x}`)// prints 42
Or, alternatively:
// Run with and without --experimental-test-module-mocksimport{writeFile}from'node:fs/promises'import{mock}from'node:test'awaitwriteFile('./test-1.mjs',"import x from './test-2'; console.log(`Found x: ${x}`)")awaitwriteFile('./test-2.js',"export default 42")try{if(mock.module)mock.module('Whatever, this is not significant',{namedExports: {}})}catch{}awaitimport('./test-1.mjs')// prints 42
Or, alternatively (dir imports):
// Run with and without --experimental-test-module-mocksimport{writeFile,mkdir}from'node:fs/promises'import{mock}from'node:test'awaitmkdir('./test-3',{recursive: true})awaitwriteFile('./test-3/index.js',"export default 43")try{if(mock.module)mock.module('Whatever, this is not significant',{namedExports: {}})}catch{}const{default: x}=awaitimport('./test-3')console.log(`Found x: ${x}`)// prints 43
How often does it reproduce? Is there a required condition?
Always, when run with --experimental-test-module-mocks
What is the expected behavior? Why is that the expected behavior?
Error [ERR_MODULE_NOT_FOUND]: Cannot find module './test-2' imported from ./test-1.mjsDid you mean to import "./test-2.js"?
The text was updated successfully, but these errors were encountered:
ChALkeR
changed the title
test_runner: using module mocking confuses all future esm imports to load .js suffix by default
test_runner: using module mocking confuses all future esm imports to use cjs path resolution
Jul 11, 2024
Version
v22.4.1
Platform
Subsystem
test_runner
What steps will reproduce the bug?
Or, alternatively:
Or, alternatively (dir imports):
How often does it reproduce? Is there a required condition?
Always, when run with
--experimental-test-module-mocks
What is the expected behavior? Why is that the expected behavior?
What do you see instead?
Additional information
Likely from #52848, cc @cjihrig, @nodejs/test_runner
Also: long time no see, hi all!
The text was updated successfully, but these errors were encountered: