Use when jest configuration, setup files, module resolution, and project organization for optimal testing environments.
View on GitHubTheBushidoCollective/han
jutsu-jest
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/TheBushidoCollective/han/blob/main/jutsu/jutsu-jest/skills/jest-configuration/SKILL.md -a claude-code --skill jest-configurationInstallation paths:
.claude/skills/jest-configuration/# Jest Configuration
Master Jest configuration, setup files, module resolution, and project organization for optimal testing environments. This skill covers all aspects of configuring Jest for modern JavaScript and TypeScript projects, from basic setup to advanced multi-project configurations.
## Installation and Setup
### Basic Installation
```bash
# npm
npm install --save-dev jest
# yarn
yarn add --dev jest
# pnpm
pnpm add -D jest
```
### TypeScript Support
```bash
npm install --save-dev @types/jest ts-jest
```
### React Testing Libraries
```bash
npm install --save-dev @testing-library/react @testing-library/jest-dom
```
## Configuration Files
### jest.config.js (Recommended)
```javascript
/** @type {import('jest').Config} */
module.exports = {
// Test environment
testEnvironment: 'node', // or 'jsdom' for browser-like environment
// Root directory for tests
roots: ['<rootDir>/src'],
// File extensions to consider
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json'],
// Test match patterns
testMatch: [
'**/__tests__/**/*.[jt]s?(x)',
'**/?(*.)+(spec|test).[jt]s?(x)'
],
// Transform files before testing
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest'
},
// Coverage configuration
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.stories.{js,jsx,ts,tsx}',
'!src/**/__tests__/**'
],
// Coverage thresholds
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
},
// Setup files
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// Module name mapper for imports
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/__mocks__/fileMock.js'
},
// Clear mocks between tests
clearMocks: true,
// Restore mocks between tests
restoreMocks: true,
// Verbose o