summaryrefslogtreecommitdiff
path: root/test/es-module/test-cjs-esm-warn.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/es-module/test-cjs-esm-warn.js')
-rw-r--r--test/es-module/test-cjs-esm-warn.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/es-module/test-cjs-esm-warn.js b/test/es-module/test-cjs-esm-warn.js
index b1b2e7f434..b800a47d05 100644
--- a/test/es-module/test-cjs-esm-warn.js
+++ b/test/es-module/test-cjs-esm-warn.js
@@ -26,15 +26,19 @@ child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);
- assert.ok(stderr.startsWith(`(node:${child.pid}) Warning: ` +
- 'require() of ES modules is not supported.\nrequire() of ' +
+ assert.ok(stderr.indexOf(
+ `Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ${required}` +
+ '\nrequire() of ES modules is not supported.\nrequire() of ' +
`${required} from ${requiring} ` +
'is an ES module file as it is a .js file whose nearest parent ' +
'package.json contains "type": "module" which defines all .js ' +
'files in that package scope as ES modules.\nInstead rename ' +
`${basename} to end in .cjs, change the requiring code to use ` +
'import(), or remove "type": "module" from ' +
- `${pjson}.\n`));
+ `${pjson}.\n`) !== -1);
assert.ok(stderr.indexOf(
'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module') !== -1);
+
+ assert.strictEqual(
+ stderr.match(/Must use import to load ES Module/g).length, 1);
}));