javascript-typescript-jest

Guides writing Jest tests for JavaScript and TypeScript with mocking and matchers.

Updated Jul 25, 2026
One-click install
npx skills add https://github.com/kaannakiin/turborepo_template --skill javascript-typescript-jest-kaannakiin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: javascript-typescript-jest
Source: https://github.com/kaannakiin/turborepo_template/tree/main/.agents/skills/javascript-typescript-jest
Command: npx skills add https://github.com/kaannakiin/turborepo_template --skill javascript-typescript-jest-kaannakiin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, well-structured Jest tests is hard when teams lack shared conventions for test organization, mocking, async handling, and assertions, leading to flaky and hard-to-maintain test suites. ## Core Features & Use Cases - Test Structure Conventions: Enforces naming patterns, describe/it organization, and descriptive test names for readable suites. - Mocking Strategies: Covers jest.mock(), jest.spyOn(), mock implementations, and mock reset patterns to isolate units under test. - Async, Snapshot, and React Testing: Provides guidance on promises, snapshot testing, and React Testing Library practices including userEvent over fireEvent. - Use Case: When adding tests to a TypeScript service that calls an external API, apply the mocking guidance to stub the API layer and use the matcher reference to write precise assertions. ## Quick Start Write Jest tests for my TypeScript utility module following best practices for structure, mocking, and assertions.

Frequently Asked Questions about javascript-typescript-jest

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

FAQPage Schema
How do I mock a module in Jest?

Use jest.mock() for module-level mocks and jest.spyOn() for mocking specific functions. Define behavior with mockImplementation() or mockReturnValue(), and reset mocks between tests with jest.resetAllMocks() in afterEach.

How to test async code with Jest?

Always return promises or use async/await syntax in tests. Use the resolves and rejects matchers for promise assertions, and set appropriate timeouts for slow tests with jest.setTimeout().

Should I use React Testing Library or Enzyme for Jest tests?

Use React Testing Library over Enzyme for testing components. Test user behavior and accessibility, query elements by roles, labels, or text content, and prefer userEvent over fireEvent for realistic interactions.

When should I use snapshot testing in Jest?

Use snapshot tests for UI components or complex objects that change infrequently. Keep snapshots small and focused, and review snapshot changes carefully before committing them.

Where should Jest test files be placed?

Name test files with the .test.ts or .test.js suffix. Place them next to the code they test or in a dedicated __tests__ directory, and organize related tests with nested describe blocks.