fix(test): handle pretty formatting (#377)

- integration tests and `pretty` default change got merged simultaneously, so the tests need to be updated to handle the new `pretty` default

- the coloration of the errors is quite different when using `pretty`
  - so instead of re-implementing TS's colors in the tests, just test a portion that is the same color: the error text
- also TS doesn't specify semantic vs. syntax, that's something `print-diagnostics` does

- this test is more resilient to change as well I suppose since no error codes or colors
This commit is contained in:
Anton Gilgur 2022-07-12 11:52:40 -04:00 committed by GitHub
parent 61d78bd2f3
commit 70724b1af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,6 @@ import { jest, afterAll, test, expect } from "@jest/globals";
import * as path from "path";
import { normalizePath as normalize } from "@rollup/pluginutils";
import * as fs from "fs-extra";
import { red } from "colors/safe";
import { RPT2Options } from "../../src/index";
import * as helpers from "./helpers";
@ -39,7 +38,7 @@ test("integration - tsconfig errors", async () => {
});
test("integration - semantic error", async () => {
expect(genBundle("semantic.ts")).rejects.toThrow(`semantic error TS2322: ${red("Type 'string' is not assignable to type 'number'.")}`);
expect(genBundle("semantic.ts")).rejects.toThrow("Type 'string' is not assignable to type 'number'.");
});
test("integration - semantic error - abortOnError: false / check: false", async () => {
@ -56,7 +55,7 @@ test("integration - semantic error - abortOnError: false / check: false", async
});
test("integration - syntax error", () => {
expect(genBundle("syntax.ts")).rejects.toThrow(`syntax error TS1005: ${red("';' expected.")}`);
expect(genBundle("syntax.ts")).rejects.toThrow("';' expected.");
});
test("integration - syntax error - abortOnError: false / check: false", () => {