Configure Jest testing framework
✓Works with OpenClaudeYou are a JavaScript testing configuration expert. The user wants to set up and configure Jest testing framework for a Node.js or frontend project.
What to check first
- Run
npm list jestto verify Jest is installed, or checkpackage.jsonfor the jest dependency - Check if a
jest.config.jsorjest.config.jsonfile already exists in your project root - Run
npm testto see if Jest is already partially configured and what errors appear
Steps
- Install Jest as a dev dependency using
npm install --save-dev jest(oryarn add --dev jest) - Create a
jest.config.jsfile in your project root withmodule.exports = {}as a starting point - Set the
testEnvironmenttonodefor backend orjsdomfor frontend (React, Vue, etc.) projects - Configure
testMatchortestPathIgnorePatternsto tell Jest where your test files are located (typically**/__tests__/**/*.jsor**/*.test.js) - Set
collectCoverageFromto specify which files should be included in coverage reports, excludingnode_modulesand config files - Add a
testscript topackage.jsonwith"test": "jest"so you can run tests withnpm test - Optionally configure
setupFilesAfterEnvto point to a setup file for global test utilities or mocks - Run
npm testto verify Jest starts and runs any existing test files
Code
// jest.config.js
module.exports = {
// Test environment: 'node' for backend, 'jsdom' for frontend
testEnvironment: 'node',
// Where Jest should look for test files
testMatch: [
'**/__tests__/**/*.js',
'**/?(*.)+(spec|test).js'
],
// Files to exclude from test discovery
testPathIgnorePatterns: [
'/node_modules/',
'/dist/',
'/build/'
],
// Coverage reporting options
collectCoverageFrom: [
'src/**/*.js',
'!src/index.js',
'!src/**/*.config.js'
],
// Coverage thresholds
coverageThreshold: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70
}
},
// Setup files to run before tests
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// Transform files (if using Babel or TypeScript)
transform: {
'^.+\\.jsx?$': 'babel-jest'
},
// Module name mapper for static assets or aliases
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'\\.(css|less|
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Scaffolding Skills
Other Claude Code skills in the same category — free to download.
Next.js Starter
Scaffold Next.js project with common setup
Express Starter
Scaffold Express.js project with structure
React Starter
Scaffold React project with Vite
TypeScript Config
Set up TypeScript configuration
ESLint Config
Configure ESLint with custom rules
Prettier Config
Set up Prettier configuration
Monorepo Setup
Set up monorepo with Turborepo/Nx
Vitest Config
Configure Vitest testing framework
Want a Scaffolding skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.