jest-configuration

Configure Jest with setup files and module resolution for JavaScript and TypeScript projects.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill jest-configuration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jest-configuration
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-jest/skills/jest-configuration
Command: npx skills add https://github.com/TheBushidoCollective/han --skill jest-configuration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Master Jest configuration, setup files, module resolution, and project organization for reliable JavaScript/TypeScript testing.

Core Features & Use Cases

  • Jest config with testEnvironment, roots, moduleFileExtensions
  • Transform setup for TS and JS, type-safe TS config
  • Setup files and global matchers for consistent test behavior

Quick Start

Create a Jest config with appropriate roots, transforms, and setupFilesAfterEnv for your project.

Frequently Asked Questions about jest-configuration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure Jest for TypeScript projects?

Configure Jest for TypeScript by setting up ts-jest as your transform, specifying moduleFileExtensions to include .ts and .tsx, and configuring testEnvironment based on your runtime. Use a jest.config.js or package.json jest field with appropriate roots and testMatch patterns to locate your test files.

What Jest configuration do I need for React testing with testing-library?

For React testing-library projects, configure testEnvironment to jsdom, set up setupFilesAfterEnv to load testing-library matchers, use moduleNameMapper to handle CSS and asset imports, and configure transform for both JavaScript and TypeScript. Include collectCoverageFrom and coverageThreshold to enforce test coverage standards.

How do I set up Jest in a monorepo or multi-project repository?

Configure Jest with projects array specifying roots and testMatch for each project, or use separate jest.config.js files per workspace. Set moduleFileExtensions, transform, and setupFilesAfterEnv consistently across projects to ensure reliable test execution and coverage collection across repositories.

Can I use Jest with both JavaScript and TypeScript files in the same project?

Yes. Configure moduleFileExtensions with both .js and .ts extensions, set up transform to handle both file types using ts-jest or babel, and ensure testMatch patterns capture both .test.js and .test.ts files. This works for mixed-language projects and monorepos.

What setup files and global matchers do I need for consistent test behavior?

Use setupFilesAfterEnv to load matchers and global configuration after Jest environment initialization. Configure clearMocks and restoreMocks to control state between tests, and define custom matchers or extend built-in ones in setup files to ensure predictable test isolation and consistent assertions.

Why aren't my Jest tests finding files or running correctly?

Check testMatch patterns, roots, and moduleFileExtensions match your project layout. Verify transform is configured for your file types, moduleNameMapper handles non-JS imports, and setupFilesAfterEnv paths are correct. Use verbose output to diagnose resolution and execution issues.