Skip to content

Commit

Permalink
fix(test): handle pretty formatting (#377)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
agilgur5 authored Jul 12, 2022
1 parent 61d78bd commit 70724b1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions __tests__/integration/errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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", () => {
Expand Down

0 comments on commit 70724b1

Please sign in to comment.