From 5e617f58c62e5e7f50e0d1eb89d850efd9e618b8 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Fri, 21 Jul 2023 20:31:14 -0700 Subject: [PATCH] fixup! add more tests --- test/es-module/test-esm-loader-hooks.mjs | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/es-module/test-esm-loader-hooks.mjs b/test/es-module/test-esm-loader-hooks.mjs index 2994f8170eb221..591e6cbfd3852a 100644 --- a/test/es-module/test-esm-loader-hooks.mjs +++ b/test/es-module/test-esm-loader-hooks.mjs @@ -645,4 +645,48 @@ describe('Loader hooks', { concurrency: true }, () => { assert.strictEqual(code, 0); assert.strictEqual(signal, null); }); + + it('`register` should work with `require`', {skip: 'hangs forever'}, async () => { + const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ + '--no-warnings', + '--require', + fixtures.path('/es-module-loaders/register-loader.cjs'), + '--input-type=module', + '--eval', + ` + import 'node:os'; + `, + ]); + + const lines = stdout.split('\n'); + + assert.strictEqual(lines[0], 'resolve passthru'); + + assert.strictEqual(stderr, ''); + + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + }); + + it('`register` should work with `import`', async () => { + const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ + '--no-warnings', + '--import', + fixtures.fileURL('/es-module-loaders/register-loader.mjs'), + '--input-type=module', + '--eval', + ` + import 'node:os'; + `, + ]); + + const lines = stdout.split('\n'); + + assert.strictEqual(lines[0], 'resolve passthru'); + + assert.strictEqual(stderr, ''); + + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + }); });