
jest-generator
Skill that generates Jest unit tests for JS/TS code with mocking patterns and coverage targets.
- version
- 3.12.0
- GitHub stars
- 250
What it does
- Covers test file structure, describe blocks, setup and teardown, and proper test organization for modules
- Provides mocking patterns for dependencies, spies, timer mocking, and async testing
- Includes React component testing with Testing Library and a coverage target of 80% or higher
- Designed for adding missing test coverage to JavaScript or TypeScript modules and React components
Generate Jest unit tests for JavaScript/TypeScript with mocking, coverage. Use for JS/TS modules, React components, test generation, or encountering missing coverage, improper mocking, test structure errors.
Add marketplace
/plugin marketplace add secondsky/claude-skillsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install jest-generator@claude-skillsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourceJest Generator Skill
Purpose
Generate Jest-based unit tests for JavaScript and TypeScript code, following Jest conventions and best practices with proper mocking, describe blocks, and code organization.
When to Use
- Generate Jest tests for JavaScript/TypeScript modules
- Create test files for React components
- Add missing test coverage to existing code
- Need Jest-specific patterns (mocks, spies, snapshots)
Test File Naming
Source to Test Mapping:
src/components/Feature.tsx→src/components/Feature.test.tsxsrc/utils/validator.ts→src/utils/validator.test.tssrc/models/User.ts→src/models/User.test.ts
Running Tests
# Preferred: Using bun (faster)
bun test
# Run specific file
bun test src/utils/validator.test.ts
# Run with coverage
bun test --coverage
# Watch mode
bun test --watch
# Alternative: Using npm
npm test
npm test -- --coverage
Jest Test Structure
import { functionToTest, ClassToTest } from './Feature'
jest.mock('./dependency')
describe('ModuleName', () => {
beforeEach(() => {
jest.clearAllMocks()
})
afterEach(() => {
jest.restoreAllMocks()
})
describe('ClassName', () => {
let instance: ClassToTest
beforeEach(() => {
instance = new ClassToTest()
})
it('should return expected result with valid input', () => {
// Arrange
const input = { key: 'value' }
const expected = { processed: true }
// Act
const result = instance.method(input)
// Assert
expect(result).toEqual(expected)
})
it('should throw error with invalid input', () => {
expect(() => instance.method(null)).toThrow('Invalid input')
})
})
})
Jest-Specific Patterns
Mocking
// Mock entire module
jest.mock('./api', () => ({
fetchData: jest.fn(),
}))
// Mock with implementation
const mockFn = jest.fn((x: number) => x * 2)
// Spy on method
const spy = jest.spyOn(obj, 'method').mockReturnValue('mocked')
spy.mockRestore()
Async Testing
it('should resolve with data', async () => {
const result = await asyncFunction()
expect(result).toBeDefined()
})
it('should reject with error', async () => {
await expect(asyncFunction()).rejects.toThrow('Error')
})
Timers
beforeEach(() => jest.useFakeTimers())
afterEach(() => jest.useRealTimers())
it('should execute after timeout', () => {
const callback = jest.fn()
setTimeout(callback, 1000)
jest.advanceTimersByTime(1000)
expect(callback).toHaveBeenCalled()
})
Common Matchers
// Equality
expect(value).toBe(expected)
expect(value).toEqual(expected)
// Truthiness
expect(value).toBeTruthy()
expect(value).toBeNull()
expect(value).toBeDefined()
// Arrays/Objects
expect(array).toContain(item)
expect(obj).toHaveProperty('key')
// Functions/Promises
expect(fn).toThrow('error')
await expect(promise).resolves.toBe(value)
// Mock functions
expect(mockFn).toHaveBeenCalled()
expect(mockFn).toHaveBeenCalledWith(arg)
React Component Testing
import { render, screen, fireEvent } from '@testing-library/react'
import '@testing-library/jest-dom'
import { Button } from './Button'
describe('Button', () => {
it('should call onClick when clicked', () => {
const handleClick = jest.fn()
render(<Button onClick={handleClick}>Click me</Button>)
fireEvent.click(screen.getByText('Click me'))
expect(handleClick).toHaveBeenCalledTimes(1)
})
})
Quality Checklist
- Test file properly named (
<module>.test.ts) - All exported functions/classes tested
- Happy path and edge cases included
- Error conditions tested
- External dependencies mocked
- Tests organized with describe blocks
- beforeEach/afterEach for setup/cleanup
- Descriptive test names
- Coverage ≥ 80%
Best Practices
- Use descriptive test names:
should <expected> when <condition> - Organize with describe blocks
- Mock external dependencies only
- Test user behavior for components
- Use test.each for parametrized tests
- Keep tests independent
- Test error conditions
- Aim for 80%+ coverage
Readme
Jest Generator Skill
Generate Jest-based unit tests for JavaScript/TypeScript code with proper mocking and coverage.
Overview
This skill generates comprehensive Jest test suites following best practices including mocking, describe blocks, setup/teardown, and proper test organization.
When to Use
- Generate Jest tests for JS/TS modules
- Create test files for React components
- Add missing test coverage
- Need Jest-specific patterns (mocks, spies, snapshots)
Features
- Automatic test file structure generation
- Proper mocking patterns for dependencies
- Async testing patterns
- Timer mocking
- React component testing with Testing Library
- Coverage targets (80%+)
Quick Start
# Run tests (prefer bun)
bun test
# With coverage
bun test --coverage
# Watch mode
bun test --watch
Auto-Trigger Keywords
- jest testing
- unit test generation
- javascript testing
- typescript testing
- react component tests
- test coverage
- mock dependencies
Source
Adapted from matteocervelli/llms
Details
- Marketplace
- secondsky/claude-skills
- Source
- plugins/jest-generator
- Category
- Testing
- Keywords
- jest-generator, jest, generator, testing, tests, unit-tests, quality
- Listed since
- Apr 7, 2026
More from secondsky/claude-skills
All 122- kpi-dashboard-designv3.12.0
- logging-best-practicesv3.12.0
- maz-uiv3.12.0
- microservices-patternsv3.12.0
- ml-model-trainingv3.12.0
- ml-pipeline-automationv3.12.0
- mobile-app-debuggingv3.12.0
- mobile-app-testingv3.12.0
- mobile-first-designv3.12.0
- mobile-offline-supportv3.12.0
- model-deploymentv3.12.0
- motionv3.12.0
- multi-ai-consultantv3.12.0
- mutation-testingv3.12.0
- nano-banana-promptsv3.12.0
- nextjsv3.12.0
- nuxt-contentv3.12.0
- nuxt-seov3.12.0
- nuxt-studiov3.12.0
- nuxt-ui-v4v3.12.0
- nuxt-v4v3.12.0
- nuxt-v5v3.12.0
- oauth-implementationv3.12.0
- payment-gateway-integrationv3.12.0
Similar to jest-generator
More Testing & QA
jest-generatorSkillsecondsky/claude-skills395 installsGenerates Jest unit tests for JavaScript and TypeScript with mocking, async handling, and React component coverage.
jestPluginTheBushidoCollective/han201 starsComprehensive Jest testing framework skills for JavaScript and TypeScript projects.
unit-testing-test-generateSkillsickn33/agentic-awesome-skills431 installsGenerate comprehensive unit tests across languages, with scaffolds for pytest, Jest, and React component testing.
jutsu-vitestPluginTheBushidoCollective/han201 starsComprehensive Vitest testing framework skills for modern Vite-powered JavaScript and TypeScript projects.
unit-testingPluginwshobson/agents42.8K starsUnit and integration test automation for Python and JavaScript with debugging support
test-writerPluginrohitg00/awesome-claude-code-toolkit2.8K starsGenerate comprehensive unit and integration tests with full coverage