Agent skill · software engineering · wshobson

javascript-testing-patterns

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.

Why this skill is useful

Provides specific Jest and Vitest configuration examples and testing patterns that enhance the AI's ability to implement testing strategies in JavaScript/TypeScript applications.

What it needs

Requires jest, vitest installed locally. About 6k tokens when loaded. Last updated 2026-08-05. 38,570 stars on the source repository.

What this skill does

JavaScript Testing Patterns Comprehensive guide for implementing robust testing strategies in JavaScript/TypeScript applications using modern testing frameworks and best practices. When to Use This Skill Setting up test infrastructure for new projects Writing unit tests for functions and classes Creating integration tests for APIs and services Implementing end-to-end tests for user flows Mocking external dependencies and APIs Testing React, Vue, or other frontend components Implementing test-driven development (TDD) Setting up continuous testing in CI/CD pipelines Testing Frameworks Jest - Full-Featured Testing Framework Setup: Vitest - Fast, Vite-Native Testing Setup: Unit Testing Patterns Pattern 1: Testing Pure Functions Pattern 2: Testing Classes Pattern 3: Testing Async Functions Mocking Patterns Pattern 1: Mocking Modules Pattern 2: Dependency Injection for Testing Pattern 3: Spying on Functions Integration Testing Integration tests verify real database operations and HTTP endpoints using supertest and a test database instance. Always truncate tables in beforeEach and tear down in afterAll. For full API integration test examples (supertest + PostgreSQL) and database repository integration tests, see references/advanced-testing-patterns.md. Frontend Testing with Testing Library Test React components by rendering them and querying by role, placeholder, or test ID. Test hooks with renderHook + act. Prefer semantic queries (getByRole, getByPlaceholderText) over data-testid. For complete React component test examples (UserForm, hooks with renderHook/act), see references/advanced-testing-patterns.md. Test Fixtures and Factories Use @faker-js/faker to generate realistic test data factories. Factories accept optional overrides so tests can set only the fields they care about: For snapshot testing, coverage configuration, test organization patterns, promise testing, and timer mocking, see references/advanced-testing-patterns.md. Best Practices 1. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills wshobson/javascript-testing-patterns

View the source on GitHub

Browse the @skills marketplace