From b9c491594e87e7cc0389dfc010b186013f3c95bc Mon Sep 17 00:00:00 2001 From: Fran Herrero Date: Tue, 6 Nov 2018 16:36:32 +0000 Subject: [PATCH] test: esm loader unknown builtin module --- .../loader-unknown-builtin-module.mjs | 6 ++++++ .../parallel/test-loaders-unknown-builtin-module.mjs | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs create mode 100644 test/parallel/test-loaders-unknown-builtin-module.mjs diff --git a/test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs b/test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs new file mode 100644 index 00000000000000..e7c6c8ff345617 --- /dev/null +++ b/test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs @@ -0,0 +1,6 @@ +export async function resolve(specifier, parent, defaultResolve) { + if (specifier === 'unknown-builtin-module') { + return { url: 'unknown-builtin-module', format: 'builtin' }; + } + return defaultResolve(specifier, parent); +} \ No newline at end of file diff --git a/test/parallel/test-loaders-unknown-builtin-module.mjs b/test/parallel/test-loaders-unknown-builtin-module.mjs new file mode 100644 index 00000000000000..db3cfa3582e9e2 --- /dev/null +++ b/test/parallel/test-loaders-unknown-builtin-module.mjs @@ -0,0 +1,12 @@ +// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs +import { expectsError, mustCall } from '../common'; +import assert from 'assert'; + +const unknownBuiltinModule = 'unknown-builtin-module'; + +import(unknownBuiltinModule) +.then(assert.fail, expectsError({ + code: 'ERR_UNKNOWN_BUILTIN_MODULE', + message: `No such built-in module: ${unknownBuiltinModule}` +})) +.then(mustCall());