Files
node/test/es-module/test-require-esm-from-imported-cjs.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

37 lines
930 B
JavaScript

'use strict';
// This tests that the require(esm) works from an imported CJS module
// when the require-d ESM is cached separately.
require('../common');
const { spawnSyncAndAssert } = require('../common/child_process');
const fixtures = require('../common/fixtures');
spawnSyncAndAssert(
process.execPath,
[
'--experimental-require-module',
'--import',
fixtures.fileURL('es-modules', 'require-esm-in-cjs-cache', 'instrument-sync.js'),
fixtures.path('es-modules', 'require-esm-in-cjs-cache', 'app.cjs'),
],
{
trim: true,
stdout: / default: { hello: 'world' }/,
}
);
spawnSyncAndAssert(
process.execPath,
[
'--experimental-require-module',
'--import',
fixtures.fileURL('es-modules', 'require-esm-in-cjs-cache', 'instrument.js'),
fixtures.path('es-modules', 'require-esm-in-cjs-cache', 'app.cjs'),
],
{
trim: true,
stdout: / default: { hello: 'world' }/,
}
);