Configures and runs Jest - Meta-built batteries-included JS/TS unit framework with built-in `expect`, snapshot testing, mocking (`jest.mock`, `jest.fn`, `jest.spyOn`, manual `__mocks__/`), test environment selection (`jsdom` / `node`), parallel workers, coverage via Istanbul, watch mode, and CI integration via `--ci` flag. Use when the user works with React (CRA / older Next.js) or Node services and needs the most ecosystem-supported JS test framework.
75
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Deep reference for jest-tests SKILL.md. Consult when generating or tuning
jest.config.js - test environment, coverage collection, path aliases.
Generate config (per jest-start):
npm init jest@latestCommon jest.config.js settings:
module.exports = {
testEnvironment: 'jsdom', // 'jsdom' for browser; 'node' for backend
setupFilesAfterEach: ['<rootDir>/jest.setup.js'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
collectCoverageFrom: ['src/**/*.{js,ts}', '!src/**/*.d.ts'],
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1', // path aliases matching tsconfig
},
};testEnvironment defaults to jsdom in Jest 26 and earlier; from Jest 27+
defaults to node. Set explicitly to avoid surprise.