$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
Scaffoldingbeginner

Jest Config

Share

Configure Jest testing framework

Works with OpenClaude

You 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 jest to verify Jest is installed, or check package.json for the jest dependency
  • Check if a jest.config.js or jest.config.json file already exists in your project root
  • Run npm test to see if Jest is already partially configured and what errors appear

Steps

  1. Install Jest as a dev dependency using npm install --save-dev jest (or yarn add --dev jest)
  2. Create a jest.config.js file in your project root with module.exports = {} as a starting point
  3. Set the testEnvironment to node for backend or jsdom for frontend (React, Vue, etc.) projects
  4. Configure testMatch or testPathIgnorePatterns to tell Jest where your test files are located (typically **/__tests__/**/*.js or **/*.test.js)
  5. Set collectCoverageFrom to specify which files should be included in coverage reports, excluding node_modules and config files
  6. Add a test script to package.json with "test": "jest" so you can run tests with npm test
  7. Optionally configure setupFilesAfterEnv to point to a setup file for global test utilities or mocks
  8. Run npm test to 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

Quick Info

CategoryScaffolding
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
scaffoldingjesttesting

Install command:

curl -o ~/.claude/skills/jest-config.md https://claude-skills-hub.vercel.app/skills/scaffolding/jest-config.md

Related Scaffolding Skills

Other Claude Code skills in the same category — free to download.

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.