summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-09-12 19:53:57 +1000
committerGitHub <noreply@github.com>2020-09-12 11:53:57 +0200
commit10fbfcbc79eb50cb7669b4aaf67f957d97d8d93b (patch)
tree99bbe8fcf2bb554f2203d990252556924e1cc18c /cli/tests
parent5276cc85923a1791bf73a91b05c27fbdeeaa6f9b (diff)
refactor: improve tsc diagnostics (#7420)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/format_error_test.ts30
1 files changed, 18 insertions, 12 deletions
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) {