Installation & Basic Setup in Jest

From the Jest cheat sheet · Setup & Configuration · verified Jul 2026

Installation & Basic Setup

Setting up Jest in your JavaScript/TypeScript project

javascript
# Install Jest
npm install --save-dev jest
# For TypeScript support
npm install --save-dev @types/jest ts-jest

# package.json scripts
{
  "scripts": {
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage"
  }
}
💡 Use test:watch for TDD workflow with automatic re-runs
⚡ Add coverage thresholds to enforce code quality standards
📌 Configure testMatch to find your test files correctly
🟢 Start with node environment, switch to jsdom for DOM testing
setupconfiguration
Back to the full Jest cheat sheet