Skip to content

Commit e29c945

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 e43a4e0 commit e29c945

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
@@ -772,6 +772,19 @@ describe('Loader hooks', { concurrency: !process.env.TEST_PARALLEL }, () => {
772772
assert.strictEqual(signal, null);
773773
});
774774

775+
describe('should use hooks', async () => {
776+
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
777+
'--import',
778+
fixtures.fileURL('es-module-loaders/builtin-named-exports.mjs'),
779+
fixtures.path('es-modules/require-esm-throws-with-loaders.js'),
780+
]);
781+
782+
assert.strictEqual(stderr, '');
783+
assert.strictEqual(stdout, '');
784+
assert.strictEqual(code, 0);
785+
assert.strictEqual(signal, null);
786+
});
787+
775788
it('should support source maps in commonjs translator', async () => {
776789
const readFile = async () => {};
777790
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)