Jest Testing CLI — Test Like a Professional
Run, watch, and analyze your test suite entirely from the terminal:
Setup Jest in Project:
```cmd
npm install --save-dev jest @types/jest ts-jest
npx ts-jest config:init
`
Essential Jest Commands:
```cmd
npx jest # Run all tests once
npx jest --watch # Watch mode (interactive)
npx jest --coverage # Generate coverage report
npx jest --onlyChanged # Only changed files
npx jest src/api/auth.test.ts # Run specific test file
npx jest --verbose # Detailed test output
`
Coverage Report:
`
--------------------|--------|----------|---------|---------|
File | % Stmts| % Branch | % Funcs | % Lines |
--------------------|--------|----------|---------|---------|
All files | 87.5 | 75 | 90 | 87.5 |
auth/loginHandler | 100 | 100 | 100 | 100 |
utils/validator.ts | 75 | 50 | 80 | 75 |
`
Aim for 80%+ coverage on critical business logic! 🎯
