jest-testing-expert

Configure Jest tests for JavaScript and TypeScript projects with mocking and snapshots.

218|14|Updated Apr 5, 2025
One-click install
npx skills add https://github.com/cin12211/orca-q --skill jest-testing-expert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jest-testing-expert
Source: https://github.com/cin12211/orca-q/tree/main/.agent/skills/jest-expert
Command: npx skills add https://github.com/cin12211/orca-q --skill jest-testing-expert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables teams to craft reliable, maintainable Jest tests for JavaScript and TypeScript projects by providing in-depth guidance on configuration, mocking strategies, snapshot testing, and robust async patterns.

Core Features & Use Cases

  • Advanced configuration mastery: finely tune Jest settings, timers, module resolution, and environment to fit large codebases.
  • Advanced mocking & isolation: hoisting rules, manual mocks, and precise control over dependencies across modules.
  • Snapshot testing & matchers: create stable snapshots and custom matchers to improve test readability.
  • Async testing & concurrency: patterns for promises, callbacks, and parallel test execution across CI.

Quick Start

Install Jest in your project and, if using TypeScript, ts-jest. Create a setupTests file to register custom matchers and reset mocks between runs. Run tests with npm test or pnpm test to start validating your codebase.

Frequently Asked Questions about jest-testing-expert

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

FAQPage Schema
How do I configure Jest with ts-jest for a TypeScript project?

To configure Jest with ts-jest, install both packages and adjust your Jest configuration to use the ts-jest preset. This setup enables TypeScript transpilation, ensuring your unit tests run correctly within TypeScript codebases.

What is the best way to handle async testing and promises in Jest?

The best way to handle async testing in Jest is to apply specific patterns for promises and callbacks. Proper async testing ensures that asynchronous operations resolve correctly before assertions run, preventing race conditions and flaky tests in your test suite.

How do mocking and hoisting rules work in Jest?

Mocking and hoisting in Jest work by automatically elevating mock declarations to the top of the test file. Understanding these hoisting rules is essential for achieving precise dependency isolation and preventing scope errors during manual mocking.

Does Jest support snapshot testing for React and Vue components?

Yes, Jest supports snapshot testing for React and Vue components. Snapshot testing captures the rendered output of components, allowing you to create stable snapshots and use custom matchers to detect unexpected UI changes.

How do I optimize Jest for CI and parallel test execution?

To optimize Jest for CI, configure parallel test execution and adjust environment settings for large codebases. CI optimization reduces test runtime and resource consumption by efficiently managing concurrency across continuous integration pipelines.

Why are my Jest timer mocks not working correctly?

Jest timer mocks may not work correctly if configuration settings are improperly tuned or mock resets are skipped. Mastering timer mocks requires precise control over dependency lifecycles and module resolution to ensure synchronous time-based testing.