diff --git a/test/es-module/test-esm-loader-hooks.mjs b/test/es-module/test-esm-loader-hooks.mjs index 8e616c0d517823..a82d23df03dfd6 100644 --- a/test/es-module/test-esm-loader-hooks.mjs +++ b/test/es-module/test-esm-loader-hooks.mjs @@ -737,6 +737,19 @@ describe('Loader hooks', { concurrency: true }, () => { assert.strictEqual(signal, null); }); + describe('should use hooks', async () => { + const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [ + '--import', + fixtures.fileURL('es-module-loaders/builtin-named-exports.mjs'), + fixtures.path('es-modules/require-esm-throws-with-loaders.js'), + ]); + + assert.strictEqual(stderr, ''); + assert.strictEqual(stdout, ''); + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + }); + it('should support source maps in commonjs translator', async () => { const readFile = async () => {}; const hook = ` diff --git a/test/es-module/test-esm-named-exports.js b/test/es-module/test-esm-named-exports.js deleted file mode 100644 index 2c6f67288aa57c..00000000000000 --- a/test/es-module/test-esm-named-exports.js +++ /dev/null @@ -1,11 +0,0 @@ -// Flags: --import ./test/fixtures/es-module-loaders/builtin-named-exports.mjs -'use strict'; - -require('../common'); -const { readFile, __fromLoader } = require('fs'); -const assert = require('assert'); - -assert.throws(() => require('../fixtures/es-modules/test-esm-ok.mjs'), { code: 'ERR_REQUIRE_ESM' }); - -assert(readFile); -assert(__fromLoader); diff --git a/test/fixtures/es-modules/require-esm-throws-with-loaders.js b/test/fixtures/es-modules/require-esm-throws-with-loaders.js new file mode 100644 index 00000000000000..79c5cf96c14141 --- /dev/null +++ b/test/fixtures/es-modules/require-esm-throws-with-loaders.js @@ -0,0 +1,8 @@ +'use strict'; +const { readFile, __fromLoader } = require('fs'); +const assert = require('assert'); + +assert.throws(() => require('./test-esm-ok.mjs'), { code: 'ERR_REQUIRE_ESM' }); + +assert(readFile); +assert(__fromLoader);