Test your code using Jest with tests written in TypeScript.
-
Add as a dependency:
yarn add --dev @alot/jest-preset
-
Create a
tsconfig.json
configuration in your app root if you haven't already, for example:{ "compilerOptions": { "target": "es2015", "jsx": "react", "noEmit": true, "moduleResolution": "node" }, "exclude": [ "node_modules" ] }
-
Modify your
package.json
or other Jest configuration to use this preset:
package.json
example:
{
+ "jest": {
+ "preset": "@alot/jest-preset",
+ ...
}
```
4. That's it!