- Install:
- jest:
npm install --save-dev jest
- ts-jest:
npm install --save-dev ts-jest @types/jest
- Modify package.json
"jest": {
"transform": {
"^.+\\.tsx?$": "ts-jest"
import { useState } from 'react'; | |
export function useCounter(initial = 0) { | |
const [count, setCount] = useState(initial); | |
return [count, () => setCount(count + 1)]; | |
} |