2024-10-18 16:48:19 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
2024-12-09 15:47:25 +01:00
|
|
|
// This checks the warning and the stack trace emitted by --trace-require-module=all.
|
2024-10-18 16:48:19 +02:00
|
|
|
require('../common');
|
|
|
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
|
|
spawnSyncAndAssert(process.execPath, [
|
|
|
|
|
'--trace-warnings',
|
2024-12-09 15:47:25 +01:00
|
|
|
'--trace-require-module=all',
|
2024-10-18 16:48:19 +02:00
|
|
|
fixtures.path('es-modules', 'require-module.js'),
|
|
|
|
|
], {
|
|
|
|
|
trim: true,
|
|
|
|
|
stderr(output) {
|
|
|
|
|
const lines = output.split('\n');
|
|
|
|
|
assert.match(
|
|
|
|
|
lines[0],
|
|
|
|
|
/ExperimentalWarning: CommonJS module .*require-module\.js is loading ES Module .*message\.mjs/
|
|
|
|
|
);
|
|
|
|
|
assert.strictEqual(
|
|
|
|
|
lines[1],
|
|
|
|
|
'Support for loading ES Module in require() is an experimental feature and might change at any time'
|
|
|
|
|
);
|
|
|
|
|
assert.match(
|
|
|
|
|
lines[2],
|
|
|
|
|
/at require \(.*modules\/helpers:\d+:\d+\)/
|
|
|
|
|
);
|
|
|
|
|
assert.match(
|
|
|
|
|
lines[3],
|
|
|
|
|
/at Object\.<anonymous> \(.*require-module\.js:1:1\)/
|
|
|
|
|
);
|
2025-11-29 15:10:12 +01:00
|
|
|
},
|
2024-10-18 16:48:19 +02:00
|
|
|
});
|
2024-12-09 15:47:25 +01:00
|
|
|
|
|
|
|
|
spawnSyncAndAssert(process.execPath, [
|
|
|
|
|
'--trace-require-module=1',
|
|
|
|
|
fixtures.path('es-modules', 'require-module.js'),
|
|
|
|
|
], {
|
|
|
|
|
status: 9,
|
|
|
|
|
trim: true,
|
2025-11-29 15:10:12 +01:00
|
|
|
stderr: /invalid value for --trace-require-module/,
|
2024-12-09 15:47:25 +01:00
|
|
|
});
|