jest-generator_skill

This skill generates Jest unit tests for JavaScript and TypeScript code, including mocks, describe blocks, and coverage-friendly patterns.
  • TypeScript

52

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill secondsky/claude-skills --skill jest-generator

  • SKILL.md4.4 KB

Overview

This skill generates Jest unit tests for JavaScript and TypeScript projects, producing production-ready test files with proper structure, mocking, and coverage hints. It targets modules and React components and focuses on maintainable tests that follow Jest conventions. Use it to add missing coverage, fix improper mocking, or scaffold well-organized test suites quickly.

How this skill works

The generator inspects source files and maps them to .test.ts/.test.tsx counterparts, scaffolding describe blocks, beforeEach/afterEach hooks, and common matchers. It inserts Jest-specific patterns: module mocks, spies, async tests, timers, and React Testing Library setups when components are detected. Outputs include runnable examples, coverage reminders, and a checklist to reach 80%+ coverage.

When to use it

  • Create unit tests for JS/TS modules or classes
  • Generate test files for React components using Testing Library
  • Add or restore missing coverage in an existing codebase
  • Fix improper mocking, spies, or async test patterns
  • Standardize test file naming and structure across a repo

Best practices

  • Name test files to mirror source: Component.tsx → Component.test.tsx
  • Group related specs with describe and keep tests independent
  • Mock external dependencies only; restore spies after each test
  • Cover happy paths, edge cases, and error conditions explicitly
  • Use test.each for parameterized cases and aim for ≥80% coverage

Example use cases

  • Scaffold tests for a utility module with sync and async functions, including mocks for network calls
  • Create React component tests that assert UI behavior and event handling with fireEvent and screen queries
  • Add failing tests to drive fixes for uncovered edge cases and increase coverage
  • Replace ad-hoc mocks with jest.mock and jest.spyOn patterns and restore afterwards

FAQ

It maps source files to same-folder test files: .ts → .test.ts and .tsx → .test.tsx so tests live alongside implementation.

Will it handle async functions and timers?

Yes. It generates async/await test bodies, rejects/resolves assertions, and optional fake timer setup with advanceTimersByTime when needed.

How does it recommend running tests?

It suggests running tests with bun test for speed, or npm test as an alternative, and includes flags for coverage and watch mode.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational