mirror of
https://github.com/nodejs/node.git
synced 2025-12-28 07:50:41 +00:00
PR-URL: https://github.com/nodejs/node/pull/60891 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
22 lines
703 B
JavaScript
22 lines
703 B
JavaScript
'use strict';
|
|
// This tests that in the require() in imported CJS can retry loading an ESM with TLA
|
|
// twice and get the correct error both times.
|
|
|
|
require('../common');
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
const fixtures = require('../common/fixtures');
|
|
const assert = require('assert');
|
|
|
|
spawnSyncAndAssert(
|
|
process.execPath,
|
|
['--import', fixtures.fileURL('es-modules', 'import-require-tla-twice', 'hook.js'),
|
|
fixtures.path('es-modules', 'import-require-tla-twice', 'require-tla.js'),
|
|
],
|
|
{
|
|
stdout(output) {
|
|
const matches = output.matchAll(/e\.code === ERR_REQUIRE_ASYNC_MODULE true/g);
|
|
assert.strictEqual([...matches].length, 2);
|
|
},
|
|
}
|
|
);
|