From 70724b1af58f393c848a681ba2d87a449d7c8c84 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Tue, 12 Jul 2022 11:52:40 -0400 Subject: [PATCH] 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 --- __tests__/integration/errors.spec.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/__tests__/integration/errors.spec.ts b/__tests__/integration/errors.spec.ts index cc40cbe..5838ed8 100644 --- a/__tests__/integration/errors.spec.ts +++ b/__tests__/integration/errors.spec.ts @@ -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", () => {