Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
secondsky avatar

Jest Generator

  • 296 installs
  • 202 repo stars
  • Updated August 4, 2026
  • secondsky/claude-skills

jest-generator is a Claude Code skill that generates Jest unit tests with mocking and describe-block structure for developers who need JavaScript or TypeScript test coverage.

About

jest-generator is an MIT-licensed Claude Code skill that writes Jest-based unit tests for JavaScript and TypeScript modules and React components. It follows Jest conventions with describe blocks, proper mocking, and organized test file structure when developers encounter missing coverage, improper mocks, or test layout errors. The skill is triggered for JS/TS module test generation, React component test files, and coverage gap remediation. Allowed tools include Read, Write, Edit, Bash, Grep, and Glob so agents can inspect source files and write matching spec files. Developers reach for jest-generator when adding tests to untested modules, fixing broken mock patterns, or bootstrapping a Jest suite without manually copying boilerplate from documentation.

  • jest-generator

Jest Generator by the numbers

  • 296 all-time installs (skills.sh)
  • +14 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #1,361 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/claude-skills --skill jest-generator

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs296
repo stars202
Last updatedAugust 4, 2026
Repositorysecondsky/claude-skills

How do you generate Jest tests for React components?

Use jest-generator for development tasks

Who is it for?

Developers writing JavaScript or TypeScript who need Jest unit tests with proper mocking for modules or React components.

Skip if: Developers using Vitest, Playwright E2E suites, or Python pytest who need a non-Jest testing framework.

When should I use this skill?

The user needs Jest tests generated, has missing unit test coverage, or reports improper mocking or test structure errors.

What you get

Jest spec files with describe blocks, mock setups, and organized test cases aligned to source modules.

  • Jest spec files
  • Mock configurations
  • Describe-block test suites

By the numbers

  • Allows 6 agent tools: Read, Write, Edit, Bash, Grep, and Glob
  • MIT-licensed Jest generator skill for JavaScript and TypeScript

Files

SKILL.mdMarkdownGitHub ↗

Jest 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.tsxsrc/components/Feature.test.tsx
  • src/utils/validator.tssrc/utils/validator.test.ts
  • src/models/User.tssrc/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

1. Use descriptive test names: should <expected> when <condition> 2. Organize with describe blocks 3. Mock external dependencies only 4. Test user behavior for components 5. Use test.each for parametrized tests 6. Keep tests independent 7. Test error conditions 8. Aim for 80%+ coverage

Related skills

How it compares

Pick jest-generator when the test runner is Jest and you want agent-authored unit tests with mocks rather than E2E or Vitest-based suites.

FAQ

What languages does jest-generator support?

The jest-generator skill targets JavaScript and TypeScript modules and React components. It writes Jest spec files following standard describe-block and mock patterns for those codebases.

When should I invoke jest-generator?

The jest-generator skill activates when you need Jest tests for JS/TS modules, React component specs, missing test coverage, or when existing tests have improper mocking or structure errors.

Which tools can jest-generator use?

The jest-generator skill allows Read, Write, Edit, Bash, Grep, and Glob so agents can read source files, search the repo, and write Jest test files alongside existing code.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.