[build-utils] Convert unit.test to TypeScript and fix jest types in VS Code (#6527)

Makes the `test/unit.test.ts` file be TypeScript, and import from the source TypeScript code. This way, we don't need to run `yarn build` to test local changes when testing.

Also, VS Code was complaining about the types for jest `describe()`/`it()` not being installed, even though they are. After some digging, I found that TypeScript has a peculiar behavior with types in monorepo setups. [This solution](https://github.com/microsoft/TypeScript-Node-Starter/issues/196#issuecomment-771988960) describing adding a `tsconfig.json` inside of the `tests` dir seems to do the trick.
This commit is contained in:
Nathan Rajlich
2021-07-28 13:49:42 -07:00
committed by GitHub
parent e271c2598e
commit f036162aa3
7 changed files with 1654 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
preset: 'ts-jest',
testEnvironment: 'node',
};