Skip to content

Commit

Permalink
fix(jest-runtime): fix node:-prefixed modules loading
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Aug 31, 2021
1 parent 98f10e6 commit 335f0a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/jest-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1361,10 +1361,9 @@ export default class Runtime {
}

private _requireCoreModule(moduleName: string, supportPrefix: boolean) {
const moduleWithoutNodePrefix =
supportPrefix && moduleName.startsWith('node:')
? moduleName.slice('node:'.length)
: moduleName;
const moduleWithoutNodePrefix = moduleName.startsWith('node:')
? moduleName.slice('node:'.length)
: moduleName;

if (moduleWithoutNodePrefix === 'process') {
return this._environment.global.process;
Expand All @@ -1374,7 +1373,7 @@ export default class Runtime {
return this._getMockedNativeModule();
}

return require(moduleWithoutNodePrefix);
return require(supportPrefix ? moduleName : moduleWithoutNodePrefix);
}

private _importCoreModule(moduleName: string, context: VMContext) {
Expand Down

0 comments on commit 335f0a4

Please sign in to comment.