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)
This commit is contained in:
Anton Gilgur 2022-08-19 17:00:24 -04:00 committed by GitHub
parent d286015ad2
commit 576558e082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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");
});