Agent skill

Jest Generator

by secondsky in secondsky/claude-skills

Generate Jest unit tests for JavaScript/TypeScript with mocking, coverage.

MITAuto-check: notesTesting & QA

Install Jest Generator

skills CLI
$ npx skills add secondsky/claude-skills --skill jest-generator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install secondsky/claude-skills jest-generator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/secondsky/claude-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/jest-generator/skills/jest-generator .claude/skills/jest-generator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
jest-generator
GitHub stars
227
Token cost
~1.1k tokens
SKILL.md length
166 words
Files
1
Skills in repo
169
Repo updated
First seen
Licence
MIT

At a glance

Generate Jest unit tests for JavaScript/TypeScript with mocking, coverage.

  • Works in 8 steps: Use descriptive test names: should when → Organize with describe blocks → Mock external dependencies only → …
  • React components
  • SKILL.md covers Purpose, When to Use, Test File Naming and Running Tests, plus 4 more sections
  • Calls bun and npm

What it does

Jest Generator is an agent skill from secondsky/claude-skills. 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.

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Unit testing and React components. It works with Jest, JavaScript and TypeScript. The repository describes itself as: Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations. The licence is MIT.

When your agent uses it

  • React components
  • Test generation
  • Encountering missing coverage
  • Improper mocking

Example prompts

  • “/jest-generator”

Requirements

  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash, Grep, Glob

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  1. Use descriptive test names: should when
  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

What it can do on your machine

Read from SKILL.md and the folder at commit 8837836. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash
    • Grep
    • Glob

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bun
    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Jest Generator loads about 1.1k tokens when it runs. Until then it costs about 56 tokens; SKILL.md has 166 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~56
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash, Grep, Glob

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from secondsky/claude-skills at commit 8837836, republished under its MIT licence (© secondsky). 166 words, ~1,128 tokens.

Download SKILL.mdSave it as .claude/skills/jest-generator/SKILL.md (or your agent's skills folder).
name
jest-generator
description
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.
allowed-tools
Read, Write, Edit, Bash, Grep, Glob
license
MIT

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

Running Tests

bash
# 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

typescript
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
typescript
// 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
typescript
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
typescript
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
typescript
// 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
typescript
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

© secondsky, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in plugins/jest-generator/skills/jest-generator of secondsky/claude-skills.

Open the folder on GitHubat commit 8837836

Compare with similar skills

Jest Generator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Jest Generator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Jest Generator this skillsecondsky/claude-skills227—~1.1kAutomated safety check: NotesMIT
Jest Skillsickn33/agentic-awesome-skills47k1 repos~1.4kAutomated safety check: PassMIT
Typescript Rulessoftspark/ai-toolkit179—~2.7kAutomated safety check: NotesApache-2.0
React Testinggetsentry/sentry45k—~2.2kAutomated safety check: PassCustom licence
Vitest Skillsickn33/agentic-awesome-skills47k1 repos~1.2kAutomated safety check: PassMIT
Javascript Typescript Jestgithub/awesome-copilot40k1 repos~559Automated safety check: PassMIT

Similar skills

  • Jest Skill

    sickn33/agentic-awesome-skills

    Generates Jest unit and integration tests in JavaScript or TypeScript.

    47k GitHub starsUsed in 1 repo~1.4k tokens
    Testing & QAAuto-check passed
  • Typescript Rules

    softspark/ai-toolkit

    TypeScript/JavaScript coding rules: style, patterns, security, testing.

    179 GitHub stars~2.7k tokensUpdated today
    Testing & QAAuto-check: notes
  • React Testing

    getsentry/sentry

    Official

    Write and review React/TypeScript tests for Sentry's frontend using Jest and React Testing Library.

    45k GitHub stars~2.2k tokensUpdated today
    Testing & QAAuto-check passed
  • Vitest Skill

    sickn33/agentic-awesome-skills

    Generates Vitest tests in JavaScript/TypeScript with Vite-native speed.

    47k GitHub starsUsed in 1 repo~1.2k tokens
    Testing & QAAuto-check passed
  • Javascript Typescript Jest

    github/awesome-copilot

    Official

    Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.

    40k GitHub starsUsed in 1 repo~559 tokens
    Testing & QAAuto-check passed
  • Jest Unit

    PramodDutta/qaskills

    Unit testing skill using Jest for TypeScript and JavaScript, covering mocking, spies, snapshots, coverage, async testing, and custom matchers.

    232 GitHub stars~3.8k tokensUpdated 3 days ago
    Testing & QAAuto-check passed

More from secondsky/claude-skills

All 169 skills in this repo
  • Tanstack AI

    secondsky/claude-skills

    TanStack AI (alpha) provider-agnostic type-safe chat with streaming for OpenAI, Anthropic, Gemini, Ollama.

    227 GitHub starsUsed in 1 repo~3.6k tokens
    Auto-check: notes
  • Auto Animate

    secondsky/claude-skills

    AutoAnimate (@formkit/auto-animate) zero-config animations for React.

    227 GitHub stars~2.9k tokensUpdated 9 days ago
    Auto-check passed
  • Base UI React

    secondsky/claude-skills

    MUI Base UI unstyled React components with Floating UI. An agent skill from secondsky/claude-skills.

    227 GitHub stars~1.9k tokensUpdated 9 days ago
    Auto-check passed
  • Cloudflare Images

    secondsky/claude-skills

    This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants"…

    227 GitHub stars~3.6k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Nextjs

    secondsky/claude-skills

    Deploy Next.js to Cloudflare Workers via the OpenNext adapter (@opennextjs/cloudflare).

    227 GitHub stars~5.3k tokensUpdated 9 days ago
    Auto-check: notes
  • Cloudflare Sandbox

    secondsky/claude-skills

    Cloudflare Sandboxes SDK for secure code execution in Linux containers at edge.

    227 GitHub stars~4.5k tokensUpdated 9 days ago
    Auto-check passed

Categories

Questions about Jest Generator

What does Jest Generator do?

Generate Jest unit tests for JavaScript/TypeScript with mocking, coverage. Jest Generator is an agent skill from secondsky/claude-skills. Generate Jest unit tests for JavaScript/TypeScript with mocking, coverage.

When should I use Jest Generator?

Jest Generator fits situations like: React components; test generation; encountering missing coverage; improper mocking.

How do I install Jest Generator in Claude Code?

Run `npx skills add secondsky/claude-skills --skill jest-generator -a claude-code`. Or copy the skill folder (plugins/jest-generator/skills/jest-generator in secondsky/claude-skills) into .claude/skills/jest-generator in your project. Claude Code loads it when a task matches its description.

How do I install Jest Generator in Codex?

Run `npx skills add secondsky/claude-skills --skill jest-generator -a codex`. Or copy the skill folder (plugins/jest-generator/skills/jest-generator in secondsky/claude-skills) into .agents/skills/jest-generator in your project. Codex loads it when a task matches its description.

Can I use Jest Generator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add secondsky/claude-skills --skill jest-generator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/jest-generator, .gemini/skills/jest-generator, .github/skills/jest-generator and .opencode/skills/jest-generator in your project.

What does Jest Generator need to run?

Going by SKILL.md and its folder, Jest Generator needs the command-line tools its instructions call (bun and npm). Its frontmatter pre-approves these tools: Read, Write, Edit, Bash, Grep, Glob.

Does Jest Generator access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Jest Generator safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Jest Generator use?

Jest Generator is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Jest Generator use?

About 1.1k tokens (SKILL.md is roughly 4.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Jest Generator?

Skills that share tags, products or a category with Jest Generator: Jest Skill (sickn33/agentic-awesome-skills, 47k stars), Typescript Rules (softspark/ai-toolkit, 179 stars), React Testing (getsentry/sentry, 45k stars) and Vitest Skill (sickn33/agentic-awesome-skills, 47k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Jest Generator?

secondsky (a GitHub user) maintains it in secondsky/claude-skills, which has 227 GitHub stars. The repository holds 169 skills in this directory. The repository was last updated on September 28, 2026.

Source: secondsky/claude-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.