From 30ee141773a652ccb63c4c50306ff1d2843ddab5 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Thu, 30 Dec 2021 12:12:53 -0800 Subject: [PATCH] fixup! esm: refactor esm tests out of test/message --- test/es-module/test-esm-export-not-found.mjs | 10 ++++++---- test/es-module/test-esm-import-json-named-export.mjs | 9 +++++---- test/es-module/test-esm-loader-not-found.mjs | 9 +++++---- test/es-module/test-esm-loader-with-syntax-error.mjs | 4 +--- .../test-esm-module-not-found-commonjs-hint.mjs | 5 +++-- test/es-module/test-esm-syntax-error.mjs | 4 +--- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/test/es-module/test-esm-export-not-found.mjs b/test/es-module/test-esm-export-not-found.mjs index 93be68fd024663..1dc44e2bbac97a 100644 --- a/test/es-module/test-esm-export-not-found.mjs +++ b/test/es-module/test-esm-export-not-found.mjs @@ -28,9 +28,11 @@ const importStatementMultiline = `import { stderr += data; }); child.on('close', () => { - ok(stderr.includes( - 'SyntaxError: The requested module \'./module-named-exports.mjs\' ' + - 'does not provide an export named \'notfound\'' - )); + // SyntaxError: The requested module './module-named-exports.mjs' + // does not provide an export named 'notfound' + ok(stderr.includes('SyntaxError:')); + // The quotes ensure that the path starts with ./ and not ../ + ok(stderr.includes('\'./module-named-exports.mjs\'')); + ok(stderr.includes('notfound')); }); }); diff --git a/test/es-module/test-esm-import-json-named-export.mjs b/test/es-module/test-esm-import-json-named-export.mjs index 5c9751caff2589..73e8e9184972b4 100644 --- a/test/es-module/test-esm-import-json-named-export.mjs +++ b/test/es-module/test-esm-import-json-named-export.mjs @@ -15,8 +15,9 @@ child.stderr.on('data', (data) => { stderr += data; }); child.on('close', () => { - ok(stderr.includes( - 'SyntaxError: The requested module \'../experimental.json\' ' + - 'does not provide an export named \'ofLife\'' - )); + // SyntaxError: The requested module '../experimental.json' + // does not provide an export named 'ofLife' + ok(stderr.includes('SyntaxError:')); + ok(stderr.includes('\'../experimental.json\'')); + ok(stderr.includes('\'ofLife\'')); }); diff --git a/test/es-module/test-esm-loader-not-found.mjs b/test/es-module/test-esm-loader-not-found.mjs index cf1ce88075da6c..545127eb2412aa 100644 --- a/test/es-module/test-esm-loader-not-found.mjs +++ b/test/es-module/test-esm-loader-not-found.mjs @@ -16,9 +16,10 @@ child.stderr.on('data', (data) => { stderr += data; }); child.on('close', () => { - ok(stderr.includes( - 'Error [ERR_MODULE_NOT_FOUND]: Cannot find package \'i-dont-exist\' ' + - 'imported from' - )); + // Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist' + // imported from + ok(stderr.includes('ERR_MODULE_NOT_FOUND')); + ok(stderr.includes('\'i-dont-exist\'')); + ok(!stderr.includes('Bad command or file name')); }); diff --git a/test/es-module/test-esm-loader-with-syntax-error.mjs b/test/es-module/test-esm-loader-with-syntax-error.mjs index 80b15b42241d96..d8ad0b5db27687 100644 --- a/test/es-module/test-esm-loader-with-syntax-error.mjs +++ b/test/es-module/test-esm-loader-with-syntax-error.mjs @@ -16,8 +16,6 @@ child.stderr.on('data', (data) => { stderr += data; }); child.on('close', () => { - ok(stderr.includes( - 'SyntaxError: Malformed arrow function parameter list' - )); + ok(stderr.includes('SyntaxError:')); ok(!stderr.includes('Bad command or file name')); }); diff --git a/test/es-module/test-esm-module-not-found-commonjs-hint.mjs b/test/es-module/test-esm-module-not-found-commonjs-hint.mjs index a406382dbf41d6..ffe26b6980ffbd 100644 --- a/test/es-module/test-esm-module-not-found-commonjs-hint.mjs +++ b/test/es-module/test-esm-module-not-found-commonjs-hint.mjs @@ -7,11 +7,12 @@ import { execPath } from 'process'; [ { input: 'import "./print-error-message"', - expected: 'Did you mean to import ../print-error-message.js?' + // Did you mean to import ../print-error-message.js? + expected: ' ../print-error-message.js?' }, { input: 'import obj from "some_module/obj"', - expected: 'Did you mean to import some_module/obj.js?' + expected: ' some_module/obj.js?' }, ].forEach(({ input, expected }) => { const child = spawn(execPath, [ diff --git a/test/es-module/test-esm-syntax-error.mjs b/test/es-module/test-esm-syntax-error.mjs index 8641605a974173..a40aba09d845b5 100644 --- a/test/es-module/test-esm-syntax-error.mjs +++ b/test/es-module/test-esm-syntax-error.mjs @@ -14,7 +14,5 @@ child.stderr.on('data', (data) => { stderr += data; }); child.on('close', () => { - ok(stderr.includes( - 'SyntaxError: Malformed arrow function parameter list' - )); + ok(stderr.includes('SyntaxError:')); });