skillfed

jest

This skill streamlines Jest configuration for TypeScript projects, handling setup automation and intelligent toolchain detection. It integrates with Claude's multi-agent ecosystem to accelerate test infrastructure deployment across diverse development stacks.

Jest streamlines TypeScript configuration through ts-jest, a TypeScript preprocessor that compiles your .ts and .tsx files on the fly. To set up Jest with TypeScript, install jest, ts-jest, and @types/jest, then create a jest.config.js file specifying ts-jest as your preset. Jest automatically detects your TypeScript files and applies the correct transformation rules, eliminating manual babel configuration. The skill handles intelligent toolchain detection to match your project structure, whether you're starting fresh or integrating into an existing codebase.

AI-generated summary based on this skill's SKILL.md

62 18 MIT updated by bobmatnyc

Install

bobmatnyc/claude-mpm-skills/jest · repository language: Python

CLI (skillfed)coming soon
git clone https://github.com/bobmatnyc/claude-mpm-skills
cp -r claude-mpm-skills/toolchains/typescript/testing/jest ~/.claude/skills/jest

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do you set up Jest with TypeScript?

Jest streamlines TypeScript configuration through ts-jest, a TypeScript preprocessor that compiles your .ts and .tsx files on the fly. To set up Jest with TypeScript, install jest, ts-jest, and @types/jest, then create a jest.config.js file specifying ts-jest as your preset. Jest automatically detects your TypeScript files and applies the correct transformation rules, eliminating manual babel configuration. The skill handles intelligent toolchain detection to match your project structure, whether you're starting fresh or integrating into an existing codebase.

What is Jest snapshot testing and when should you use it?

Jest snapshot testing captures the rendered output or serialized state of a component or function and stores it as a reference file. On subsequent test runs, Jest compares the current output against the stored snapshot to detect unintended changes. Snapshot testing is particularly valuable for React component testing, where you want to verify that UI structure remains consistent across refactors. Jest makes snapshot management straightforward—when intentional changes occur, you can update snapshots with a single command, and Jest tracks all snapshot files in version control for team collaboration.

How do you write type-safe unit tests and mock functions for TypeScript code?

Jest supports type-safe mocking through TypeScript's type system and Jest's built-in mock utilities. Use jest.fn() to create mock functions with full type inference, jest.spyOn() to spy on object methods, and jest.mock() to replace entire modules. TypeScript ensures that mock implementations match the original function signatures, catching type errors at compile time. Jest's mock functions support advanced patterns like return values, side effects, and call tracking. The skill enables developers to write comprehensive unit tests that verify both behavior and type correctness, reducing runtime errors and improving code reliability across your test suite.

Can Jest test React components and hooks using React Testing Library?

Jest integrates seamlessly with React Testing Library to test React components and hooks in a user-centric way. Jest provides the test runner and assertion framework, while React Testing Library supplies utilities like render(), screen, and fireEvent for interacting with components. For hook testing, Jest works with React Testing Library's renderHook utility to isolate and test custom hooks. Jest's snapshot testing pairs well with React component testing to catch unintended UI changes, and Jest's timer mocking (fake timers) handles async component behavior. This combination enables comprehensive React component testing across functional components, hooks, and complex user interactions.

How does Jest handle async testing patterns and promises?

Jest provides multiple patterns for testing asynchronous code: return promises directly from test functions, use async/await syntax for cleaner test code, or employ Jest's done callback for callback-based async operations. Jest automatically detects promise rejections and async errors, failing tests appropriately when promises reject. For timer-based async code, Jest's fake timers (jest.useFakeTimers()) let you control time progression and test delayed behavior without waiting for real delays. Jest also supports testing async functions that fetch data, make API calls, or perform other time-dependent operations, making it suitable for comprehensive async testing across Node.js and browser environments.

What Jest features support coverage reporting and configuration?

Jest's built-in coverage reporting generates detailed metrics for line coverage, branch coverage, function coverage, and statement coverage. Run Jest with the --coverage flag to produce coverage reports in multiple formats (text, lcov, html, json). Jest's jest.config.js supports coverage threshold configuration, allowing you to set minimum coverage percentages that fail the test suite if not met—ensuring code quality standards across your project. Jest displays coverage reports directly in the terminal and generates HTML reports for detailed analysis. The skill leverages Jest's comprehensive coverage features to help teams maintain testing standards and identify untested code paths in their TypeScript and JavaScript projects.

SKILL.md

rendered from the published skill — quoted content, verbatim

Jest + TypeScript - Industry Standard Testing

Overview

Jest is the industry-standard testing framework with 70% market share, providing a mature, battle-tested ecosystem for TypeScript projects. It offers comprehensive testing capabilities with built-in snapshot testing,

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 2 files
toolchains/typescript/testing/jest/SKILL.md
toolchains/typescript/testing/jest/metadata.json

Related skills

Tags

unit-testing test-automation mock-framework snapshot-regression code-coverage react-component-testing async-testing type-safe-mocking test-runner ci-cd-testing