From 10fbfcbc79eb50cb7669b4aaf67f957d97d8d93b Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Sat, 12 Sep 2020 19:53:57 +1000 Subject: refactor: improve tsc diagnostics (#7420) --- cli/tests/unit/format_error_test.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'cli/tests') diff --git a/cli/tests/unit/format_error_test.ts b/cli/tests/unit/format_error_test.ts index ae7559c82..f769cc18c 100644 --- a/cli/tests/unit/format_error_test.ts +++ b/cli/tests/unit/format_error_test.ts @@ -2,27 +2,33 @@ import { assert, unitTest } from "./test_util.ts"; unitTest(function formatDiagnosticBasic() { - const fixture: Deno.DiagnosticItem[] = [ + const fixture: Deno.Diagnostic[] = [ { - message: "Example error", - category: Deno.DiagnosticCategory.Error, - sourceLine: "abcdefghijklmnopqrstuv", - lineNumber: 1000, - scriptResourceName: "foo.ts", - startColumn: 1, - endColumn: 2, - code: 4000, + start: { + line: 0, + character: 0, + }, + end: { + line: 0, + character: 7, + }, + fileName: "test.ts", + messageText: + "Cannot find name 'console'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.", + sourceLine: `console.log("a");`, + category: 1, + code: 2584, }, ]; const out = Deno.formatDiagnostics(fixture); - assert(out.includes("Example error")); - assert(out.includes("foo.ts")); + assert(out.includes("Cannot find name")); + assert(out.includes("test.ts")); }); unitTest(function formatDiagnosticError() { let thrown = false; // eslint-disable-next-line @typescript-eslint/no-explicit-any - const bad = ([{ hello: 123 }] as any) as Deno.DiagnosticItem[]; + const bad = ([{ hello: 123 }] as any) as Deno.Diagnostic[]; try { Deno.formatDiagnostics(bad); } catch (e) { -- cgit v1.2.3