summaryrefslogtreecommitdiff
path: root/cli/tests/compiler_api_test.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-06-22 07:27:32 +1000
committerGitHub <noreply@github.com>2021-06-22 07:27:32 +1000
commita5eb2dfc93afc2899ed6e1ad2b3e029157889f7c (patch)
tree5fb4abf918304fa13e961cc791c7b43b26367d7c /cli/tests/compiler_api_test.ts
parent281c4cd8fcf5fd54f558a6922736def2c7804529 (diff)
fix(#10761): graph errors reported as diagnostics for `Deno.emit()` (#10767)
Fixes #10761
Diffstat (limited to 'cli/tests/compiler_api_test.ts')
-rw-r--r--cli/tests/compiler_api_test.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/cli/tests/compiler_api_test.ts b/cli/tests/compiler_api_test.ts
index b9a08d5ca..2e0a8820c 100644
--- a/cli/tests/compiler_api_test.ts
+++ b/cli/tests/compiler_api_test.ts
@@ -456,3 +456,49 @@ Deno.test({
assert(files["deno:///bundle.js.map"]);
},
});
+
+Deno.test({
+ name: `Deno.emit() - graph errors as diagnostics`,
+ ignore: Deno.build.os === "windows",
+ async fn() {
+ const { diagnostics } = await Deno.emit("/a.ts", {
+ sources: {
+ "/a.ts": `import { b } from "./b.ts";
+ console.log(b);`,
+ },
+ });
+ assert(diagnostics);
+ assertEquals(diagnostics, [
+ {
+ category: 1,
+ code: 2305,
+ start: { line: 0, character: 9 },
+ end: { line: 0, character: 10 },
+ messageText:
+ `Module '"deno:///missing_dependency.d.ts"' has no exported member 'b'.`,
+ messageChain: null,
+ source: null,
+ sourceLine: 'import { b } from "./b.ts";',
+ fileName: "file:///a.ts",
+ relatedInformation: null,
+ },
+ {
+ category: 1,
+ code: 900001,
+ start: null,
+ end: null,
+ messageText: "Unable to find specifier in sources: file:///b.ts",
+ messageChain: null,
+ source: null,
+ sourceLine: null,
+ fileName: "file:///b.ts",
+ relatedInformation: null,
+ },
+ ]);
+ assert(
+ Deno.formatDiagnostics(diagnostics).includes(
+ "Unable to find specifier in sources: file:///b.ts",
+ ),
+ );
+ },
+});