From 8a94ca7a693dbe58f65f61bea8fcabdae8973957 Mon Sep 17 00:00:00 2001 From: Geoffrey Booth <456802+GeoffreyBooth@users.noreply.github.com> Date: Thu, 6 Jan 2022 03:07:52 -0800 Subject: [PATCH] esm: refactor esm tests out of test/message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41352 Reviewed-By: Antoine du Hamel Reviewed-By: Michaƫl Zasso --- test/common/fixtures.js | 6 +++ test/common/fixtures.mjs | 2 + test/es-module/test-esm-export-not-found.mjs | 39 +++++++++++++++++++ .../test-esm-import-json-named-export.mjs | 25 ++++++++++++ test/es-module/test-esm-loader-not-found.mjs | 27 +++++++++++++ .../test-esm-loader-obsolete-hooks.mjs | 30 ++++++++++++++ .../test-esm-loader-with-syntax-error.mjs | 24 ++++++++++++ ...est-esm-module-not-found-commonjs-hint.mjs | 35 +++++++++++++++++ test/es-module/test-esm-syntax-error.mjs | 19 +++++++++ .../es-module-loaders/syntax-error-import.mjs | 1 - .../es-modules/import-json-named-export.mjs | 2 + .../esm_loader_not_found_cjs_hint_bare.mjs | 5 --- test/fixtures/print-error-message.js | 1 + .../esm_display_syntax_error_import.mjs | 6 --- .../esm_display_syntax_error_import.out | 12 ------ ..._syntax_error_import_json_named_export.mjs | 4 -- ..._syntax_error_import_json_named_export.out | 12 ------ ...esm_display_syntax_error_import_module.mjs | 2 - ...esm_display_syntax_error_import_module.out | 12 ------ .../esm_display_syntax_error_module.mjs | 2 - .../esm_display_syntax_error_module.out | 9 ----- test/message/esm_import_assertion_failed.mjs | 2 - test/message/esm_import_assertion_failed.out | 18 --------- test/message/esm_import_assertion_missing.mjs | 3 -- test/message/esm_import_assertion_missing.out | 19 --------- .../esm_import_assertion_unsupported.mjs | 2 - .../esm_import_assertion_unsupported.out | 19 --------- test/message/esm_loader_not_found.mjs | 3 -- test/message/esm_loader_not_found.out | 20 ---------- .../esm_loader_not_found_cjs_hint_bare.js | 17 -------- .../esm_loader_not_found_cjs_hint_bare.out | 18 --------- ...esm_loader_not_found_cjs_hint_relative.mjs | 3 -- ...esm_loader_not_found_cjs_hint_relative.out | 22 ----------- test/message/esm_loader_syntax_error.mjs | 3 -- test/message/esm_loader_syntax_error.out | 12 ------ .../test-esm-loader-obsolete-hooks.mjs | 4 -- .../test-esm-loader-obsolete-hooks.out | 11 ------ 37 files changed, 210 insertions(+), 241 deletions(-) create mode 100644 test/es-module/test-esm-export-not-found.mjs create mode 100644 test/es-module/test-esm-import-json-named-export.mjs create mode 100644 test/es-module/test-esm-loader-not-found.mjs create mode 100644 test/es-module/test-esm-loader-obsolete-hooks.mjs create mode 100644 test/es-module/test-esm-loader-with-syntax-error.mjs create mode 100644 test/es-module/test-esm-module-not-found-commonjs-hint.mjs create mode 100644 test/es-module/test-esm-syntax-error.mjs delete mode 100644 test/fixtures/es-module-loaders/syntax-error-import.mjs create mode 100644 test/fixtures/es-modules/import-json-named-export.mjs delete mode 100644 test/fixtures/esm_loader_not_found_cjs_hint_bare.mjs create mode 100644 test/fixtures/print-error-message.js delete mode 100644 test/message/esm_display_syntax_error_import.mjs delete mode 100644 test/message/esm_display_syntax_error_import.out delete mode 100644 test/message/esm_display_syntax_error_import_json_named_export.mjs delete mode 100644 test/message/esm_display_syntax_error_import_json_named_export.out delete mode 100644 test/message/esm_display_syntax_error_import_module.mjs delete mode 100644 test/message/esm_display_syntax_error_import_module.out delete mode 100644 test/message/esm_display_syntax_error_module.mjs delete mode 100644 test/message/esm_display_syntax_error_module.out delete mode 100644 test/message/esm_import_assertion_failed.mjs delete mode 100644 test/message/esm_import_assertion_failed.out delete mode 100644 test/message/esm_import_assertion_missing.mjs delete mode 100644 test/message/esm_import_assertion_missing.out delete mode 100644 test/message/esm_import_assertion_unsupported.mjs delete mode 100644 test/message/esm_import_assertion_unsupported.out delete mode 100644 test/message/esm_loader_not_found.mjs delete mode 100644 test/message/esm_loader_not_found.out delete mode 100644 test/message/esm_loader_not_found_cjs_hint_bare.js delete mode 100644 test/message/esm_loader_not_found_cjs_hint_bare.out delete mode 100644 test/message/esm_loader_not_found_cjs_hint_relative.mjs delete mode 100644 test/message/esm_loader_not_found_cjs_hint_relative.out delete mode 100644 test/message/esm_loader_syntax_error.mjs delete mode 100644 test/message/esm_loader_syntax_error.out delete mode 100644 test/message/test-esm-loader-obsolete-hooks.mjs delete mode 100644 test/message/test-esm-loader-obsolete-hooks.out diff --git a/test/common/fixtures.js b/test/common/fixtures.js index e5e1d887df525e..3ee87e8b2d7b59 100644 --- a/test/common/fixtures.js +++ b/test/common/fixtures.js @@ -2,6 +2,7 @@ const path = require('path'); const fs = require('fs'); +const { pathToFileURL } = require('url'); const fixturesDir = path.join(__dirname, '..', 'fixtures'); @@ -9,6 +10,10 @@ function fixturesPath(...args) { return path.join(fixturesDir, ...args); } +function fixturesFileURL(...args) { + return pathToFileURL(fixturesPath(...args)); +} + function readFixtureSync(args, enc) { if (Array.isArray(args)) return fs.readFileSync(fixturesPath(...args), enc); @@ -26,6 +31,7 @@ function readFixtureKeys(enc, ...names) { module.exports = { fixturesDir, path: fixturesPath, + fileURL: fixturesFileURL, readSync: readFixtureSync, readKey: readFixtureKey, readKeys: readFixtureKeys, diff --git a/test/common/fixtures.mjs b/test/common/fixtures.mjs index 06564de6fa3bb9..d6f7f6c092aaa9 100644 --- a/test/common/fixtures.mjs +++ b/test/common/fixtures.mjs @@ -3,6 +3,7 @@ import fixtures from './fixtures.js'; const { fixturesDir, path, + fileURL, readSync, readKey, } = fixtures; @@ -10,6 +11,7 @@ const { export { fixturesDir, path, + fileURL, readSync, readKey, }; diff --git a/test/es-module/test-esm-export-not-found.mjs b/test/es-module/test-esm-export-not-found.mjs new file mode 100644 index 00000000000000..cdfe6df0fcde31 --- /dev/null +++ b/test/es-module/test-esm-export-not-found.mjs @@ -0,0 +1,39 @@ +import { mustCall } from '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; +import { match, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +const importStatement = + 'import { foo, notfound } from \'./module-named-exports.mjs\';'; +const importStatementMultiline = `import { + foo, + notfound +} from './module-named-exports.mjs'; +`; + +[importStatement, importStatementMultiline].forEach((input) => { + const child = spawn(execPath, [ + '--input-type=module', + '--eval', + input, + ], { + cwd: path('es-module-loaders'), + }); + + let stderr = ''; + child.stderr.setEncoding('utf8'); + child.stderr.on('data', (data) => { + stderr += data; + }); + child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + + // SyntaxError: The requested module './module-named-exports.mjs' + // does not provide an export named 'notfound' + match(stderr, /SyntaxError:/); + // The quotes ensure that the path starts with ./ and not ../ + match(stderr, /'\.\/module-named-exports\.mjs'/); + match(stderr, /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 new file mode 100644 index 00000000000000..f70b927329b6a6 --- /dev/null +++ b/test/es-module/test-esm-import-json-named-export.mjs @@ -0,0 +1,25 @@ +import { mustCall } from '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; +import { match, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +const child = spawn(execPath, [ + '--experimental-json-modules', + path('es-modules', 'import-json-named-export.mjs'), +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + + // SyntaxError: The requested module '../experimental.json' + // does not provide an export named 'ofLife' + match(stderr, /SyntaxError:/); + match(stderr, /'\.\.\/experimental\.json'/); + match(stderr, /'ofLife'/); +})); diff --git a/test/es-module/test-esm-loader-not-found.mjs b/test/es-module/test-esm-loader-not-found.mjs new file mode 100644 index 00000000000000..275f0b0f1e8515 --- /dev/null +++ b/test/es-module/test-esm-loader-not-found.mjs @@ -0,0 +1,27 @@ +import { mustCall } from '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; +import { match, ok, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +const child = spawn(execPath, [ + '--experimental-loader', + 'i-dont-exist', + path('print-error-message.js'), +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + + // Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist' + // imported from + match(stderr, /ERR_MODULE_NOT_FOUND/); + match(stderr, /'i-dont-exist'/); + + ok(!stderr.includes('Bad command or file name')); +})); diff --git a/test/es-module/test-esm-loader-obsolete-hooks.mjs b/test/es-module/test-esm-loader-obsolete-hooks.mjs new file mode 100644 index 00000000000000..eff4104fc265ae --- /dev/null +++ b/test/es-module/test-esm-loader-obsolete-hooks.mjs @@ -0,0 +1,30 @@ +import { mustCall } from '../common/index.mjs'; +import { fileURL, path } from '../common/fixtures.mjs'; +import { match, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +const child = spawn(execPath, [ + '--no-warnings', + '--throw-deprecation', + '--experimental-loader', + fileURL('es-module-loaders', 'hooks-obsolete.mjs').href, + path('print-error-message.js'), +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + + // DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: + // dynamicInstantiate, getFormat, getSource, transformSource + match(stderr, /DeprecationWarning:/); + match(stderr, /dynamicInstantiate/); + match(stderr, /getFormat/); + match(stderr, /getSource/); + match(stderr, /transformSource/); +})); diff --git a/test/es-module/test-esm-loader-with-syntax-error.mjs b/test/es-module/test-esm-loader-with-syntax-error.mjs new file mode 100644 index 00000000000000..d973e72975e88f --- /dev/null +++ b/test/es-module/test-esm-loader-with-syntax-error.mjs @@ -0,0 +1,24 @@ +import { mustCall } from '../common/index.mjs'; +import { fileURL, path } from '../common/fixtures.mjs'; +import { match, ok, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +const child = spawn(execPath, [ + '--experimental-loader', + fileURL('es-module-loaders', 'syntax-error.mjs').href, + path('print-error-message.js'), +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + + match(stderr, /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 new file mode 100644 index 00000000000000..58f70d0b685391 --- /dev/null +++ b/test/es-module/test-esm-module-not-found-commonjs-hint.mjs @@ -0,0 +1,35 @@ +import { mustCall } from '../common/index.mjs'; +import { fixturesDir } from '../common/fixtures.mjs'; +import { match, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +[ + { + input: 'import "./print-error-message"', + // Did you mean to import ../print-error-message.js? + expected: / \.\.\/print-error-message\.js\?/, + }, + { + input: 'import obj from "some_module/obj"', + expected: / some_module\/obj\.js\?/, + }, +].forEach(({ input, expected }) => { + const child = spawn(execPath, [ + '--input-type=module', + '--eval', + input, + ], { + cwd: fixturesDir, + }); + + let stderr = ''; + child.stderr.setEncoding('utf8'); + child.stderr.on('data', (data) => { + stderr += data; + }); + child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + match(stderr, expected); + })); +}); diff --git a/test/es-module/test-esm-syntax-error.mjs b/test/es-module/test-esm-syntax-error.mjs new file mode 100644 index 00000000000000..a8c019171717dd --- /dev/null +++ b/test/es-module/test-esm-syntax-error.mjs @@ -0,0 +1,19 @@ +import { mustCall } from '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; +import { match, notStrictEqual } from 'assert'; +import { spawn } from 'child_process'; +import { execPath } from 'process'; + +const child = spawn(execPath, [ + path('es-module-loaders', 'syntax-error.mjs'), +]); + +let stderr = ''; +child.stderr.setEncoding('utf8'); +child.stderr.on('data', (data) => { + stderr += data; +}); +child.on('close', mustCall((code, _signal) => { + notStrictEqual(code, 0); + match(stderr, /SyntaxError:/); +})); diff --git a/test/fixtures/es-module-loaders/syntax-error-import.mjs b/test/fixtures/es-module-loaders/syntax-error-import.mjs deleted file mode 100644 index 3a6bc5effc1940..00000000000000 --- a/test/fixtures/es-module-loaders/syntax-error-import.mjs +++ /dev/null @@ -1 +0,0 @@ -import { foo, notfound } from './module-named-exports.mjs'; diff --git a/test/fixtures/es-modules/import-json-named-export.mjs b/test/fixtures/es-modules/import-json-named-export.mjs new file mode 100644 index 00000000000000..f491e8c252d41a --- /dev/null +++ b/test/fixtures/es-modules/import-json-named-export.mjs @@ -0,0 +1,2 @@ +/* eslint-disable no-unused-vars */ +import { ofLife } from '../experimental.json' assert { type: 'json' }; diff --git a/test/fixtures/esm_loader_not_found_cjs_hint_bare.mjs b/test/fixtures/esm_loader_not_found_cjs_hint_bare.mjs deleted file mode 100644 index 4eb5f190af43e4..00000000000000 --- a/test/fixtures/esm_loader_not_found_cjs_hint_bare.mjs +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -import obj from 'some_module/obj'; - -throw new Error('Should have errored'); diff --git a/test/fixtures/print-error-message.js b/test/fixtures/print-error-message.js new file mode 100644 index 00000000000000..0650bfbd52bafa --- /dev/null +++ b/test/fixtures/print-error-message.js @@ -0,0 +1 @@ +console.error('Bad command or file name'); diff --git a/test/message/esm_display_syntax_error_import.mjs b/test/message/esm_display_syntax_error_import.mjs deleted file mode 100644 index 2173cb2b2e3a71..00000000000000 --- a/test/message/esm_display_syntax_error_import.mjs +++ /dev/null @@ -1,6 +0,0 @@ -/* eslint-disable no-unused-vars */ -import '../common/index.mjs'; -import { - foo, - notfound -} from '../fixtures/es-module-loaders/module-named-exports.mjs'; diff --git a/test/message/esm_display_syntax_error_import.out b/test/message/esm_display_syntax_error_import.out deleted file mode 100644 index babdcfc934bdd3..00000000000000 --- a/test/message/esm_display_syntax_error_import.out +++ /dev/null @@ -1,12 +0,0 @@ -file:///*/test/message/esm_display_syntax_error_import.mjs:5 - notfound - ^^^^^^^^ -SyntaxError: The requested module '../fixtures/es-module-loaders/module-named-exports.mjs' does not provide an export named 'notfound' - at ModuleJob._instantiate (node:internal/modules/esm/module_job:*:*) - at async ModuleJob.run (node:internal/modules/esm/module_job:*:*) - at async Promise.all (index 0) - at async ESMLoader.import (node:internal/modules/esm/loader:*:*) - at async loadESM (node:internal/process/esm_loader:*:*) - at async handleMainPromise (node:internal/modules/run_main:*:*) - -Node.js * diff --git a/test/message/esm_display_syntax_error_import_json_named_export.mjs b/test/message/esm_display_syntax_error_import_json_named_export.mjs deleted file mode 100644 index fc14340467856b..00000000000000 --- a/test/message/esm_display_syntax_error_import_json_named_export.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Flags: --experimental-json-modules --no-warnings -/* eslint-disable no-unused-vars */ -import '../common/index.mjs'; -import { ofLife } from '../fixtures/experimental.json' assert { type: 'json' }; diff --git a/test/message/esm_display_syntax_error_import_json_named_export.out b/test/message/esm_display_syntax_error_import_json_named_export.out deleted file mode 100644 index d4636489f27c3a..00000000000000 --- a/test/message/esm_display_syntax_error_import_json_named_export.out +++ /dev/null @@ -1,12 +0,0 @@ -file:///*/test/message/esm_display_syntax_error_import_json_named_export.mjs:* -import { ofLife } from '../fixtures/experimental.json' assert { type: 'json' }; - ^^^^^^ -SyntaxError: The requested module '../fixtures/experimental.json' does not provide an export named 'ofLife' - at ModuleJob._instantiate (node:internal/modules/esm/module_job:*:*) - at async ModuleJob.run (node:internal/modules/esm/module_job:*:*) - at async Promise.all (index 0) - at async ESMLoader.import (node:internal/modules/esm/loader:*:*) - at async loadESM (node:internal/process/esm_loader:*:*) - at async handleMainPromise (node:internal/modules/run_main:*:*) - -Node.js * diff --git a/test/message/esm_display_syntax_error_import_module.mjs b/test/message/esm_display_syntax_error_import_module.mjs deleted file mode 100644 index c0345c44fb3fda..00000000000000 --- a/test/message/esm_display_syntax_error_import_module.mjs +++ /dev/null @@ -1,2 +0,0 @@ -import '../common/index.mjs'; -import '../fixtures/es-module-loaders/syntax-error-import.mjs'; diff --git a/test/message/esm_display_syntax_error_import_module.out b/test/message/esm_display_syntax_error_import_module.out deleted file mode 100644 index af95ab469f5a31..00000000000000 --- a/test/message/esm_display_syntax_error_import_module.out +++ /dev/null @@ -1,12 +0,0 @@ -file:///*/test/fixtures/es-module-loaders/syntax-error-import.mjs:1 -import { foo, notfound } from './module-named-exports.mjs'; - ^^^^^^^^ -SyntaxError: The requested module './module-named-exports.mjs' does not provide an export named 'notfound' - at ModuleJob._instantiate (node:internal/modules/esm/module_job:*:*) - at async ModuleJob.run (node:internal/modules/esm/module_job:*:*) - at async Promise.all (index 0) - at async ESMLoader.import (node:internal/modules/esm/loader:*:*) - at async loadESM (node:internal/process/esm_loader:*:*) - at async handleMainPromise (node:internal/modules/run_main:*:*) - -Node.js * diff --git a/test/message/esm_display_syntax_error_module.mjs b/test/message/esm_display_syntax_error_module.mjs deleted file mode 100644 index da40a4ead8d3c1..00000000000000 --- a/test/message/esm_display_syntax_error_module.mjs +++ /dev/null @@ -1,2 +0,0 @@ -import '../common/index.mjs'; -import '../fixtures/es-module-loaders/syntax-error.mjs'; diff --git a/test/message/esm_display_syntax_error_module.out b/test/message/esm_display_syntax_error_module.out deleted file mode 100644 index 622e85ec759214..00000000000000 --- a/test/message/esm_display_syntax_error_module.out +++ /dev/null @@ -1,9 +0,0 @@ -file:///*/test/fixtures/es-module-loaders/syntax-error.mjs:2 -await async () => 0; -^^^^^^^^^^^^^ - -SyntaxError: Malformed arrow function parameter list - at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:*:*) - at ESMLoader.moduleProvider (node:internal/modules/esm/loader:*:*) - -Node.js * diff --git a/test/message/esm_import_assertion_failed.mjs b/test/message/esm_import_assertion_failed.mjs deleted file mode 100644 index 30ea65c3e34ee3..00000000000000 --- a/test/message/esm_import_assertion_failed.mjs +++ /dev/null @@ -1,2 +0,0 @@ -import '../common/index.mjs'; -import 'data:text/javascript,export{}' assert {type:'json'}; diff --git a/test/message/esm_import_assertion_failed.out b/test/message/esm_import_assertion_failed.out deleted file mode 100644 index eed42565166467..00000000000000 --- a/test/message/esm_import_assertion_failed.out +++ /dev/null @@ -1,18 +0,0 @@ -node:internal/errors:* - ErrorCaptureStackTrace(err); - ^ - -TypeError [ERR_IMPORT_ASSERTION_TYPE_FAILED]: Module "data:text/javascript,export{}" is not of type "json" - at new NodeError (node:internal/errors:*:*) - at handleInvalidType (node:internal/modules/esm/assert:*:*) - at validateAssertions (node:internal/modules/esm/assert:*:*) - at defaultLoad (node:internal/modules/esm/load:*:*) - at ESMLoader.load (node:internal/modules/esm/loader:*:*) - at ESMLoader.moduleProvider (node:internal/modules/esm/loader:*:*) - at new ModuleJob (node:internal/modules/esm/module_job:*:*) - at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:*:*) - at ESMLoader.getModuleJob (node:internal/modules/esm/loader:*:*) - at async ModuleWrap. (node:internal/modules/esm/module_job:*:*) { - code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' -} -Node.js * diff --git a/test/message/esm_import_assertion_missing.mjs b/test/message/esm_import_assertion_missing.mjs deleted file mode 100644 index 0b402d9e7ff90a..00000000000000 --- a/test/message/esm_import_assertion_missing.mjs +++ /dev/null @@ -1,3 +0,0 @@ -// Flags: --experimental-json-modules -import '../common/index.mjs'; -import 'data:application/json,{}'; diff --git a/test/message/esm_import_assertion_missing.out b/test/message/esm_import_assertion_missing.out deleted file mode 100644 index a56ec12aeeefb3..00000000000000 --- a/test/message/esm_import_assertion_missing.out +++ /dev/null @@ -1,19 +0,0 @@ -node:internal/errors:* - ErrorCaptureStackTrace(err); - ^ - -TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "data:application/json,{}" needs an import assertion of type "json" - at new NodeError (node:internal/errors:*:*) - at validateAssertions (node:internal/modules/esm/assert:*:*) - at defaultLoad (node:internal/modules/esm/load:*:*) - at ESMLoader.load (node:internal/modules/esm/loader:*:*) - at ESMLoader.moduleProvider (node:internal/modules/esm/loader:*:*) - at new ModuleJob (node:internal/modules/esm/module_job:*:*) - at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:*:*) - at ESMLoader.getModuleJob (node:internal/modules/esm/loader:*:*) - at async ModuleWrap. (node:internal/modules/esm/module_job:*:*) - at async Promise.all (index *) { - code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING' -} - -Node.js * diff --git a/test/message/esm_import_assertion_unsupported.mjs b/test/message/esm_import_assertion_unsupported.mjs deleted file mode 100644 index 86e594ce02ae5d..00000000000000 --- a/test/message/esm_import_assertion_unsupported.mjs +++ /dev/null @@ -1,2 +0,0 @@ -import '../common/index.mjs'; -import '../fixtures/empty.js' assert { type: 'unsupported' }; diff --git a/test/message/esm_import_assertion_unsupported.out b/test/message/esm_import_assertion_unsupported.out deleted file mode 100644 index 0dc3657e43dadb..00000000000000 --- a/test/message/esm_import_assertion_unsupported.out +++ /dev/null @@ -1,19 +0,0 @@ -node:internal/errors:* - ErrorCaptureStackTrace(err); - ^ - -TypeError [ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED]: Import assertion type "unsupported" is unsupported - at new NodeError (node:internal/errors:*:*) - at handleInvalidType (node:internal/modules/esm/assert:*:*) - at validateAssertions (node:internal/modules/esm/assert:*:*) - at defaultLoad (node:internal/modules/esm/load:*:*) - at ESMLoader.load (node:internal/modules/esm/loader:*:*) - at ESMLoader.moduleProvider (node:internal/modules/esm/loader:*:*) - at new ModuleJob (node:internal/modules/esm/module_job:*:*) - at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:*:*) - at ESMLoader.getModuleJob (node:internal/modules/esm/loader:*:*) - at async ModuleWrap. (node:internal/modules/esm/module_job:*:*) { - code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' -} - -Node.js * diff --git a/test/message/esm_loader_not_found.mjs b/test/message/esm_loader_not_found.mjs deleted file mode 100644 index 2b47e5a03ec9e6..00000000000000 --- a/test/message/esm_loader_not_found.mjs +++ /dev/null @@ -1,3 +0,0 @@ -// Flags: --experimental-loader i-dont-exist -import '../common/index.mjs'; -console.log('This should not be printed'); diff --git a/test/message/esm_loader_not_found.out b/test/message/esm_loader_not_found.out deleted file mode 100644 index 841e97d679ea3c..00000000000000 --- a/test/message/esm_loader_not_found.out +++ /dev/null @@ -1,20 +0,0 @@ -(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time -(Use `* --trace-warnings ...` to show where the warning was created) -node:internal/errors:* - ErrorCaptureStackTrace(err); - ^ -Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist' imported from * - at new NodeError (node:internal/errors:*:*) - at packageResolve (node:internal/modules/esm/resolve:*:*) - at moduleResolve (node:internal/modules/esm/resolve:*:*) - at defaultResolve (node:internal/modules/esm/resolve:*:*) - at ESMLoader.resolve (node:internal/modules/esm/loader:*:*) - at ESMLoader.getModuleJob (node:internal/modules/esm/loader:*:*) - at ESMLoader.import (node:internal/modules/esm/loader:*:*) - at initializeLoader (node:internal/process/esm_loader:*:*) - at loadESM (node:internal/process/esm_loader:*:*) - at runMainESM (node:internal/modules/run_main:*:*) { - code: 'ERR_MODULE_NOT_FOUND' -} - -Node.js * diff --git a/test/message/esm_loader_not_found_cjs_hint_bare.js b/test/message/esm_loader_not_found_cjs_hint_bare.js deleted file mode 100644 index 437fa2d3d430a1..00000000000000 --- a/test/message/esm_loader_not_found_cjs_hint_bare.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -require('../common'); -const { spawn } = require('child_process'); -const { join } = require('path'); -const { fixturesDir } = require('../common/fixtures'); - -spawn( - process.execPath, - [ - join(fixturesDir, 'esm_loader_not_found_cjs_hint_bare.mjs'), - ], - { - cwd: fixturesDir, - stdio: 'inherit' - } -); diff --git a/test/message/esm_loader_not_found_cjs_hint_bare.out b/test/message/esm_loader_not_found_cjs_hint_bare.out deleted file mode 100644 index eaa758742ff61d..00000000000000 --- a/test/message/esm_loader_not_found_cjs_hint_bare.out +++ /dev/null @@ -1,18 +0,0 @@ -node:internal/process/esm_loader:* - internalBinding('errors').triggerUncaughtException( - ^ - -Error [ERR_MODULE_NOT_FOUND]: Cannot find module '*test*fixtures*node_modules*some_module*obj' imported from *test*fixtures*esm_loader_not_found_cjs_hint_bare.mjs -Did you mean to import some_module/obj.js? - at new NodeError (node:internal/errors:*:*) - at finalizeResolution (node:internal/modules/esm/resolve:*:*) - at moduleResolve (node:internal/modules/esm/resolve:*:*) - at defaultResolve (node:internal/modules/esm/resolve:*:*) - at ESMLoader.resolve (node:internal/modules/esm/loader:*:*) - at ESMLoader.getModuleJob (node:internal/modules/esm/loader:*:*) - at ModuleWrap. (node:internal/modules/esm/module_job:*:*) - at link (node:internal/modules/esm/module_job:*:*) { - code: 'ERR_MODULE_NOT_FOUND' -} - -Node.js * diff --git a/test/message/esm_loader_not_found_cjs_hint_relative.mjs b/test/message/esm_loader_not_found_cjs_hint_relative.mjs deleted file mode 100644 index 928186318bb09a..00000000000000 --- a/test/message/esm_loader_not_found_cjs_hint_relative.mjs +++ /dev/null @@ -1,3 +0,0 @@ -// Flags: --experimental-loader ./test/common/fixtures -import '../common/index.mjs'; -console.log('This should not be printed'); diff --git a/test/message/esm_loader_not_found_cjs_hint_relative.out b/test/message/esm_loader_not_found_cjs_hint_relative.out deleted file mode 100644 index 0bd9ab7336c202..00000000000000 --- a/test/message/esm_loader_not_found_cjs_hint_relative.out +++ /dev/null @@ -1,22 +0,0 @@ -(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time -(Use `* --trace-warnings ...` to show where the warning was created) -node:internal/process/esm_loader:* - internalBinding('errors').triggerUncaughtException( - ^ - -Error [ERR_MODULE_NOT_FOUND]: Cannot find module '*test*common*fixtures' imported from * -Did you mean to import ./test/common/fixtures.js? - at new NodeError (node:internal/errors:*:*) - at finalizeResolution (node:internal/modules/esm/resolve:*:*) - at moduleResolve (node:internal/modules/esm/resolve:*:*) - at defaultResolve (node:internal/modules/esm/resolve:*:*) - at ESMLoader.resolve (node:internal/modules/esm/loader:*:*) - at ESMLoader.getModuleJob (node:internal/modules/esm/loader:*:*) - at ESMLoader.import (node:internal/modules/esm/loader:*:*) - at initializeLoader (node:internal/process/esm_loader:*:*) - at loadESM (node:internal/process/esm_loader:*:*) - at runMainESM (node:internal/modules/run_main:*:*) { - code: 'ERR_MODULE_NOT_FOUND' -} - -Node.js * diff --git a/test/message/esm_loader_syntax_error.mjs b/test/message/esm_loader_syntax_error.mjs deleted file mode 100644 index 68cde42e585644..00000000000000 --- a/test/message/esm_loader_syntax_error.mjs +++ /dev/null @@ -1,3 +0,0 @@ -// Flags: --experimental-loader ./test/fixtures/es-module-loaders/syntax-error.mjs -import '../common/index.mjs'; -console.log('This should not be printed'); diff --git a/test/message/esm_loader_syntax_error.out b/test/message/esm_loader_syntax_error.out deleted file mode 100644 index fdced9fc96b9f3..00000000000000 --- a/test/message/esm_loader_syntax_error.out +++ /dev/null @@ -1,12 +0,0 @@ -(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time -(Use `* --trace-warnings ...` to show where the warning was created) -file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2 -await async () => 0; -^^^^^^^^^^^^^ - -SyntaxError: Malformed arrow function parameter list - at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:*:*) - at ESMLoader.moduleProvider (node:internal/modules/esm/loader:*:*) - at async link (node:internal/modules/esm/module_job:*:*) - -Node.js * diff --git a/test/message/test-esm-loader-obsolete-hooks.mjs b/test/message/test-esm-loader-obsolete-hooks.mjs deleted file mode 100644 index 9a6a9c48057b40..00000000000000 --- a/test/message/test-esm-loader-obsolete-hooks.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Flags: --no-warnings --throw-deprecation --experimental-loader ./test/fixtures/es-module-loaders/hooks-obsolete.mjs -/* eslint-disable node-core/require-common-first, node-core/required-modules */ - -await import('whatever'); diff --git a/test/message/test-esm-loader-obsolete-hooks.out b/test/message/test-esm-loader-obsolete-hooks.out deleted file mode 100644 index 5453cefe2090dd..00000000000000 --- a/test/message/test-esm-loader-obsolete-hooks.out +++ /dev/null @@ -1,11 +0,0 @@ -node:internal/process/warning:* - throw warning; - ^ - -DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: dynamicInstantiate, getFormat, getSource, transformSource - at Function.pluckHooks (node:internal/modules/esm/loader:*:*) - at ESMLoader.addCustomLoaders (node:internal/modules/esm/loader:*:*) - at initializeLoader (node:internal/process/esm_loader:*:*) - at async loadESM (node:internal/process/esm_loader:*:*) - at async handleMainPromise (node:internal/modules/run_main:*:*) -Node.js * \ No newline at end of file