summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/internal/modules/cjs/loader.js2
-rw-r--r--test/es-module/test-cjs-esm-warn.js11
-rw-r--r--test/es-module/test-esm-specifiers-both-flags.mjs4
3 files changed, 6 insertions, 11 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 687d39563d..d5c6352c49 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -1169,7 +1169,7 @@ Module.prototype._compile = function(content, filename) {
} catch {
// We only expect this codepath to be reached in the case of a
// preloaded module (it will fail earlier with the main entry)
- assert(Array.isArray(getOptionValue('--require')));
+ assert(ArrayIsArray(getOptionValue('--require')));
}
} else {
resolvedArgv = 'repl';
diff --git a/test/es-module/test-cjs-esm-warn.js b/test/es-module/test-cjs-esm-warn.js
index b800a47d05..ddeda72fc8 100644
--- a/test/es-module/test-cjs-esm-warn.js
+++ b/test/es-module/test-cjs-esm-warn.js
@@ -26,7 +26,7 @@ child.on('close', common.mustCall((code, signal) => {
assert.strictEqual(code, 1);
assert.strictEqual(signal, null);
- assert.ok(stderr.indexOf(
+ assert.ok(stderr.replace(/\r/g, '').includes(
`Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: ${required}` +
'\nrequire() of ES modules is not supported.\nrequire() of ' +
`${required} from ${requiring} ` +
@@ -35,10 +35,7 @@ child.on('close', common.mustCall((code, signal) => {
'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`) !== -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);
+ `${pjson}.\n`));
+ assert.ok(stderr.includes(
+ 'Error [ERR_REQUIRE_ESM]: Must use import to load ES Module'));
}));
diff --git a/test/es-module/test-esm-specifiers-both-flags.mjs b/test/es-module/test-esm-specifiers-both-flags.mjs
index fc5c7fcd0e..a434684589 100644
--- a/test/es-module/test-esm-specifiers-both-flags.mjs
+++ b/test/es-module/test-esm-specifiers-both-flags.mjs
@@ -9,8 +9,6 @@ const expectedError =
const flags = '--es-module-specifier-resolution=node ' +
'--experimental-specifier-resolution=node';
-exec(`${process.execPath} ${flags}`, {
- timeout: 300
-}, mustCall((error) => {
+exec(`${process.execPath} ${flags}`, mustCall((error) => {
assert(error.message.includes(expectedError));
}));