Jest
Step 1: Install
npm i jest @types/jest ts-jest -DStep 2: Configure Jest
module.exports = {
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
}Step 3: Run tests
Optional: Add script target for npm scripts
Optional: Run jest in watch mode
Example
Example async
Example enzyme
Reasons why we like jest
Last updated