Skip to content

Commit

Permalink
refactor(test): use more specific checks in check-tsconfig spec (#398)
Browse files Browse the repository at this point in the history
- `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 eb1dd17)
  • Loading branch information
agilgur5 authored Aug 19, 2022
1 parent d286015 commit 576558e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions __tests__/check-tsconfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ 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",
);
options: { module: ts.ModuleKind.ES2015 },
})).not.toThrow();

expect(checkTsConfig({
expect(() => checkTsConfig({
...defaultConfig,
options: { module: ts.ModuleKind.ES2015 },
})).toBeFalsy();
options: { module: ts.ModuleKind.ES2020 },
})).not.toThrow();

expect(checkTsConfig({
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");
});

0 comments on commit 576558e

Please sign in to comment.