Skip to content

Commit

Permalink
esm: move hooks test with others
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Bota <[email protected]>
PR-URL: #53558
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
2 people authored and marco-ippolito committed Aug 19, 2024
1 parent ceb1d5e commit 5d03f6f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
13 changes: 13 additions & 0 deletions test/es-module/test-esm-loader-hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down
11 changes: 0 additions & 11 deletions test/es-module/test-esm-named-exports.js

This file was deleted.

8 changes: 8 additions & 0 deletions test/fixtures/es-modules/require-esm-throws-with-loaders.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 5d03f6f

Please sign in to comment.