02.06.2022 - Typescript / Testing with Jest
To use Jest for testing a TypeScript library, we need to install a couple of things:
yarn add -D jest @types/jest ts-jest ts-node
And set up the jest.config.ts
file to use the ts-jest
transformer when processing *.test.ts
files:
import type { Config } from '@jest/types';
const config: Config.InitialOptions = {
verbose: true,
transform: {
'^.+\\.ts?$': 'ts-jest',
}
};
export default config;
From now on, you can run jest
command to start testing every *.test.ts
file in the project.
"scripts": {
"build": "parcel build",
"test": "jest"
},
Read more
- 02.09.2022 - JavaScript/Named Imports and Dead Code Elimination
- 02.08.2022 - Cloudflare/Expose local server with Tunnel
- 02.07.2022 - Security/Timing Attack and Constant-time Compare Algorithm
- 02.05.2022 - TypeScript/Build a library with Parcel
- 02.04.2022 - JavaScript/Use any ASCII characters as a variable name