node/test/es-module/test-import-require-tla-twice.js
Antoine du Hamel 987740399d
tools: enforce trailing commas in test/es-module
PR-URL: https://github.com/nodejs/node/pull/60891
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-12-03 14:18:40 +01:00

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);
},
}
);