-
Notifications
You must be signed in to change notification settings - Fork 139
Closed
Description
Description
Importing a mocked ESM module dynamically will throw an error in node 16.17.0 but not 16.16.0.
Issue
Mocking an esm module will result on an error
Environment
-
node -voutput: v16.17.0 -
yarn --versionoutput: 1.22.19 -
yarn list testdoubleversion: [email protected]
Code-fenced Examples
❯❯❯ node --loader=testdouble script.js
(node:83826) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:83826) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, getSource
node:internal/errors:477
ErrorCaptureStackTrace(err);
^
Error [ERR_LOADER_CHAIN_INCOMPLETE]: "testdouble 'load'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
at new NodeError (node:internal/errors:387:5)
at ESMLoader.load (node:internal/modules/esm/loader:616:13)
at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:464:11)
at async link (node:internal/modules/esm/module_job:67:21) {
code: 'ERR_LOADER_CHAIN_INCOMPLETE'
}
import * as td from 'testdouble';
await td.replaceEsm('fs', {});
await import('fs');Metadata
Metadata
Assignees
Labels
No labels