From a5ac3c5eca9e1d962619c1622fc89403abfa108e Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 20 Apr 2021 12:13:45 +0200 Subject: [PATCH] chore: fix `module` test for Node v16 --- .../src/__tests__/runtime_require_module.test.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 7548e382e2aa..453373c895d8 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -384,6 +384,16 @@ describe('Runtime requireModule', () => { expect(customRequire('./create_require_module').foo).toBe('foo'); } + expect(exports.syncBuiltinESMExports).not.toThrow(); + expect(exports.builtinModules).toEqual(builtinModules); + }); + }); + + onNodeVersions('>=12.12.0 <16.0.0', () => { + it('overrides module.createRequireFromPath', async () => { + const runtime = await createRuntime(__filename); + const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); + // createRequire with relative module path expect(() => exports.createRequireFromPath('./relative/path')).toThrow( new TypeError( @@ -409,9 +419,6 @@ describe('Runtime requireModule', () => { )}'. Use createRequire for URL filename.`, ), ); - - expect(exports.syncBuiltinESMExports).not.toThrow(); - expect(exports.builtinModules).toEqual(builtinModules); }); }); });