-
-
Notifications
You must be signed in to change notification settings - Fork 730
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
Error when loading undici into jest unit tests
Logs
Tests run using:
NODE_OPTIONS=--experimental-vm-modules npx jest --run-in-band --verbose --ci
Error log:
/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:841
const error = new Error(
^
Error: Must use import to load ES Module: /home/runner/work/my-project/my-project/node_modules/undici/lib/llhttp/llhttp.wasm
at Runtime.requireModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:841:21)
at Runtime.requireModuleOrMock (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1039:21)
at lazyllhttp (/home/runner/work/my-project/my-project/node_modules/undici/lib/client.js:362:55)
at Object.<anonymous> (/home/runner/work/my-project/my-project/node_modules/undici/lib/client.js:424:21)
at Runtime._execModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1429:24)
at Runtime._loadModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1013:12)
at Runtime.requireModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:873:12)
at Runtime.requireModuleOrMock (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1039:21)
at Object.<anonymous> (/home/runner/work/my-project/my-project/node_modules/undici/index.js:3:16)
at Runtime._execModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1429:24)
at Runtime._loadModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1013:12)
at Runtime.requireModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:873:12)
at Runtime.requireModuleOrMock (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:1039:21)
at Runtime.loadCjsAsEsm (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:717:22)
at Runtime.resolveModule (/home/runner/work/my-project/my-project/node_modules/jest-runtime/build/index.js:675:17)
at ModuleWrap.<anonymous> (node:internal/vm/module:306:24) {
code: 'ERR_REQUIRE_ESM'
Environment
NodeJS: 18.15.0
Jest: 29.5.0
ts-jest: 29.0.5
ts-node: 10.9.1
typescript: 4.9.5
undici: 5.21.2
Jest config:
export default {
preset: 'ts-jest/presets/default-esm',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
extensionsToTreatAsEsm: ['.ts'],
testEnvironment: 'node',
roots: ['<rootDir>/src/']
}TS config:
{
"compilerOptions": {
"lib": ["ESNext", "DOM"],
"target": "ES2022",
"strict": false,
"module": "NodeNext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"sourceMap": true,
"declaration": true,
"declarationMap": true, // enables importers to jump to source
"removeComments": true
},
"include": ["src/**/*", "test/*"]
}Additional context
Error appears on undici v5.16.0
Possibly comes from : d0a99c2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working