diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/compiler_api_test.ts | 19 | ||||
-rw-r--r-- | cli/tests/error_import_map_unable_to_load.out | 4 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 11 |
3 files changed, 34 insertions, 0 deletions
diff --git a/cli/tests/compiler_api_test.ts b/cli/tests/compiler_api_test.ts index 04a4675b8..c6e7de651 100644 --- a/cli/tests/compiler_api_test.ts +++ b/cli/tests/compiler_api_test.ts @@ -338,3 +338,22 @@ Deno.test({ assert(files["deno:///bundle.js"].endsWith("})();\n")); }, }); + +Deno.test({ + name: `Deno.emit() - throws descriptive error when unable to load import map`, + async fn() { + await assertThrowsAsync( + async () => { + await Deno.emit("/a.ts", { + bundle: "classic", + sources: { + "/a.ts": `console.log("hello");`, + }, + importMapPath: "file:///import_map_does_not_exist.json", + }); + }, + Error, + "Unable to load 'file:///import_map_does_not_exist.json' import map", + ); + }, +}); diff --git a/cli/tests/error_import_map_unable_to_load.out b/cli/tests/error_import_map_unable_to_load.out new file mode 100644 index 000000000..50760e438 --- /dev/null +++ b/cli/tests/error_import_map_unable_to_load.out @@ -0,0 +1,4 @@ +error: Unable to load '[WILDCARD]' import map + +Caused by: + [WILDCARD]
\ No newline at end of file diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 5cbe00302..f2d1c1770 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -3841,6 +3841,17 @@ console.log("finish"); http_server: true, }); + // This test ensures that a descriptive error is shown when we're unable to load + // the import map. Even though this tests only the `run` subcommand, we can be sure + // that the error message is similar for other subcommands as they all use + // `program_state.maybe_import_map` to access the import map underneath. + itest!(error_import_map_unable_to_load { + args: + "run --import-map=import_maps/does_not_exist.json import_maps/test.ts", + output: "error_import_map_unable_to_load.out", + exit_code: 1, + }); + #[test] fn no_validate_asm() { let output = util::deno_cmd() |