From 576558e082476abd21f6827f804b4d01c23826fa Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Fri, 19 Aug 2022 17:00:24 -0400 Subject: [PATCH] refactor(test): use more specific checks in `check-tsconfig` spec (#398) - `toBeFalsy()` was a bit imprecise and always felt as such, especially since `checkTsConfig` returns `void` - so instead check that it doesn't throw, which matches the test _intent_ - reorder the tests a bit to match existing test style: non-errors first, then errors - and separating into two different test blocks parallelizes them as well - also add an ES2020 check as well (follow-up to eb1dd17babde0b22e9540b12e671eb56d9d6bce0) --- __tests__/check-tsconfig.spec.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/__tests__/check-tsconfig.spec.ts b/__tests__/check-tsconfig.spec.ts index f56fe2d..3e77e39 100644 --- a/__tests__/check-tsconfig.spec.ts +++ b/__tests__/check-tsconfig.spec.ts @@ -10,19 +10,24 @@ const defaultConfig = { fileNames: [], errors: [], options: {} }; test("checkTsConfig", () => { expect(() => checkTsConfig({ - ...defaultConfig, - options: { module: ts.ModuleKind.None }, - })).toThrow( - "Incompatible tsconfig option. Module resolves to 'None'. This is incompatible with Rollup, please use", - ); - - expect(checkTsConfig({ ...defaultConfig, options: { module: ts.ModuleKind.ES2015 }, - })).toBeFalsy(); + })).not.toThrow(); - expect(checkTsConfig({ + expect(() => checkTsConfig({ + ...defaultConfig, + options: { module: ts.ModuleKind.ES2020 }, + })).not.toThrow(); + + expect(() => checkTsConfig({ ...defaultConfig, options: { module: ts.ModuleKind.ESNext }, - })).toBeFalsy(); + })).not.toThrow(); +}); + +test("checkTsConfig - errors", () => { + expect(() => checkTsConfig({ + ...defaultConfig, + options: { module: ts.ModuleKind.None }, + })).toThrow("Incompatible tsconfig option. Module resolves to 'None'. This is incompatible with Rollup, please use"); });