diff options
Diffstat (limited to 'cli/tests/compiler_api_test.ts')
-rw-r--r-- | cli/tests/compiler_api_test.ts | 46 |
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", + ), + ); + }, +}); |