diff --git a/CHANGELOG.md b/CHANGELOG.md index 43faf3ef0199..435051230ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ - `[jest-haste-map]` Add `enableSymlinks` configuration option to follow symlinks for test files ([#9351](https://github.com/facebook/jest/pull/9351)) - `[jest-reporters]` Add static filepath property to all reporters ([#11015](https://github.com/facebook/jest/pull/11015)) - `[jest-repl, jest-runner]` [**BREAKING**] Run transforms over environment ([#8751](https://github.com/facebook/jest/pull/8751)) -- `[jest-resolver]` Support `node:` prefix when importing Node core modules +- `[jest-resolver]` Support `node:` prefix when importing Node core modules ([#11331](https://github.com/facebook/jest/pull/11331)) - `[jest-runner]` [**BREAKING**] set exit code to 1 if test logs after teardown ([#10728](https://github.com/facebook/jest/pull/10728)) - `[jest-runner]` [**BREAKING**] Run transforms over `runnner` ([#8823](https://github.com/facebook/jest/pull/8823)) - `[jest-runner]` [**BREAKING**] Run transforms over `testRunnner` ([#8823](https://github.com/facebook/jest/pull/8823)) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 63ceee649d76..3d690cba697a 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -1327,19 +1327,19 @@ export default class Runtime { } private _requireCoreModule(moduleName: string) { - const moduleWithtoutNodePrefix = moduleName.startsWith('node:') + const moduleWithoutNodePrefix = moduleName.startsWith('node:') ? moduleName.slice('node:'.length) : moduleName; - if (moduleWithtoutNodePrefix === 'process') { + if (moduleWithoutNodePrefix === 'process') { return this._environment.global.process; } - if (moduleWithtoutNodePrefix === 'module') { + if (moduleWithoutNodePrefix === 'module') { return this._getMockedNativeModule(); } - return require(moduleWithtoutNodePrefix); + return require(moduleWithoutNodePrefix); } private _importCoreModule(moduleName: string, context: VMContext) {