Jest
Step 1: Install
npm i jest @types/jest ts-jest typescript -DStep 2: Configure Jest
module.exports = {
"roots": [
"<rootDir>/src"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
},
}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