Step 1: Environment Setup
Ensure Node.js (version 18+) is installed from nodejs.org.
Create a new project:
mkdir jest-learning
cd jest-learning
npm init -y
Install Jest as dev dependency:
npm install --save-dev jest
Add test script to package.json:
"scripts": {
"test": "jest"
}
Verify installation:
This outputs Jest version (e.g., 30.2.0).