PlugWiki

JavaScript Testing Patterns Skill (wshobson) for Claude Code

javascript-testing-patterns gives Claude a set of Jest, Vitest and Testing Library test patterns to follow when you write JavaScript or TypeScript tests.

Installs
20.8K
on skills.sh
Stars
42.1K
on GitHub
Files
1
besides SKILL.md
Updated
Oct 2026
last repo commit

wshobson's javascript-testing-patterns is a reference guide. It loads when you ask Claude to write JavaScript or TypeScript tests, set up test infrastructure, or work test-first (TDD/BDD). Claude then follows its example configs and test patterns instead of improvising.

The SKILL.md shows a Jest config and a Vitest config. It then covers unit tests for pure functions, classes and async code, three mocking patterns (modules, dependency injection, spies) and fixture factories built with @faker-js/faker. Integration tests with supertest, React tests with Testing Library, snapshots, coverage, promises and timers sit in one bundled reference file.

It bundles no scripts. It is part of a large community collection (wshobson/agents), so it is not an official Jest or Vitest skill.

Good for

  • JavaScript and TypeScript developers who write tests with Claude
  • Teams setting up Jest or Vitest in a new project
  • Developers who want mocks, fixtures and React tests written in one consistent style

Install javascript-testing-patterns

Claude Code

  1. 1

    Copy this prompt.

    Install the javascript-testing-patterns skill in Claude Code. Run this command:
    
    npx skills add https://github.com/wshobson/agents --skill javascript-testing-patterns
    
    Then check that it loaded and tell me how to use it.
  2. 2

    Paste it into Claude Code. It shows the change and asks before running it.

Requires Node.js.

From its listing on skills.sh. Source.

What's in the skill

When it loads

Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or implementing TDD/BDD workflows.

Sections in SKILL.md

  1. When to Use This Skill
  2. Testing Frameworks
  3. Jest - Full-Featured Testing Framework
  4. Vitest - Fast, Vite-Native Testing
  5. Unit Testing Patterns
  6. Pattern 1: Testing Pure Functions
  7. Pattern 2: Testing Classes
  8. Pattern 3: Testing Async Functions
  9. Mocking Patterns
  10. Pattern 1: Mocking Modules
  11. Pattern 2: Dependency Injection for Testing
  12. Pattern 3: Spying on Functions
  13. Integration Testing
  14. Frontend Testing with Testing Library
  15. Test Fixtures and Factories
  16. Best Practices

Key facts

Installs on skills.sh
20,830 as of 2026-11-02
GitHub stars (whole repo)
42,081 as of 2026-11-02
License
MIT
Last repo commit
2026-10-30
Files in the skill folder
2 files including SKILL.md

What it includes

  • Example jest.config.ts and vitest.config.ts with coverage thresholds

    Config examples for Jest (ts-jest preset, 80% coverage thresholds) and Vitest (v8 coverage provider).

    Write · Jest and Vitest setup

  • Pure functions, classes and async functions

    Three patterns with describe/it examples, including error cases such as division by zero and user-already-exists.

    Write · Unit testing patterns

  • Mock modules, inject dependencies, spy on functions

    Three patterns for isolating the code under test from external services.

    Write · Mocking patterns

  • API tests with supertest and database tests

    Says to truncate tables in beforeEach and tear down in afterAll. Full examples are in references/advanced-testing-patterns.md.

    Write · Integration testing

  • React components and hooks with semantic queries

    Prefer getByRole and getByPlaceholderText over data-testid. Examples cover components and hooks (renderHook, act).

    Write · Frontend testing with Testing Library

  • Test data factories with @faker-js/faker

    Factory functions that accept overrides so each test sets only the fields it cares about.

    Write · Fixtures and factories

  • 15 rules such as AAA, test behavior not implementation, 80%+ coverage

    A numbered checklist of 15 testing habits Claude is told to follow.

    Best practices list

  • Longer examples: API and database tests, snapshots, timers

    The one bundled reference file. It holds the full integration, React, snapshot, coverage and timer examples.

    references/advanced-testing-patterns.md

From the official docs

Permissions

Low risk

What it can do

  • Read your data
  • Create and change things
  • Delete things
  • Read-only mode

Watch out for

  • Generated database tests truncate tables

    SKILL.md says integration tests should "Always truncate tables in `beforeEach` and tear down in `afterAll`". Tests written this way delete rows in whatever database they are pointed at, so use a dedicated test database. github.com

Technical details
Scopes
  • your project test files

  • your test database (integration tests)

Questions

What does the javascript-testing-patterns skill do?

It tells Claude how to write JavaScript and TypeScript tests with Jest, Vitest and Testing Library. It supplies config examples, unit, mocking and integration patterns, fixture factories and a 15-point best-practices list.

How do I install it in Claude Code or Codex?

Use the install box above. The skills CLI command installs only this skill, with no other agents or commands from the repo. The README also documents gh skill install for single skills and says it needs GitHub CLI 2.90 or later.

Does it need an API key or any other tool?

The skill itself needs no API key and bundles no scripts. Your project needs the test tools the patterns use, such as Jest or Vitest, supertest and @faker-js/faker, which you install yourself.

Is it safe to install?

It bundles no scripts: just SKILL.md and one reference file. The one instruction to watch is the integration-testing rule: "Always truncate tables in beforeEach and tear down in afterAll", so generated database tests delete rows. Point them at a throwaway test database, and review the tests and any packages Claude suggests before you run them.

Does it work for tests other than JavaScript?

No. Every example is JavaScript or TypeScript. The same repo has a separate python-testing-patterns skill, named in the README, for Python.

How is it different from the Playwright best-practices skill?

This one covers unit, integration and component testing with Jest, Vitest and Testing Library. For end-to-end browser tests with Playwright, use playwright-best-practices.

Information

updated Nov 2, 2026

Repository
wshobson/agents
Folder
plugins/javascript-typescript/skills/javascript-testing-patterns

wshobson/agentsskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 4
  1. javascript-testing-patterns SKILL.md · github.com
  2. playwright-best-practices SKILL.md · github.com
  3. advanced-testing-patterns.md · github.com
  4. wshobson/agents README · github.com

Updated Nov 2, 2026.