Skip to content

Commit 5d03f6f

Browse files
GeoffreyBoothdygabo
authored andcommitted
esm: move hooks test with others
Co-authored-by: Gabriel Bota <[email protected]> PR-URL: #53558 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent ceb1d5e commit 5d03f6f

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

test/es-module/test-esm-loader-hooks.mjs

+13
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,19 @@ describe('Loader hooks', { concurrency: true }, () => {
737737
assert.strictEqual(signal, null);
738738
});
739739

740+
describe('should use hooks', async () => {
741+
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
742+
'--import',
743+
fixtures.fileURL('es-module-loaders/builtin-named-exports.mjs'),
744+
fixtures.path('es-modules/require-esm-throws-with-loaders.js'),
745+
]);
746+
747+
assert.strictEqual(stderr, '');
748+
assert.strictEqual(stdout, '');
749+
assert.strictEqual(code, 0);
750+
assert.strictEqual(signal, null);
751+
});
752+
740753
it('should support source maps in commonjs translator', async () => {
741754
const readFile = async () => {};
742755
const hook = `

test/es-module/test-esm-named-exports.js

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
const { readFile, __fromLoader } = require('fs');
3+
const assert = require('assert');
4+
5+
assert.throws(() => require('./test-esm-ok.mjs'), { code: 'ERR_REQUIRE_ESM' });
6+
7+
assert(readFile);
8+
assert(__fromLoader);

0 commit comments

Comments
 (0)