Agent skill · software engineering · aiskillstore

tdd-vitest-typescript

Test-Driven Development (TDD) using Vitest and TypeScript. Use when the user requests help with TDD, writing tests before code, test-first development, Vitest test setup, TypeScript testing patterns, unit testing, integration testing, or following the Red-Green-Refactor cycle with Vitest.

Why this skill is useful

Provides specific Vitest testing patterns and TypeScript configurations that enhance the AI's ability to guide users in TDD workflows.

What it needs

Requires typescript, vitest installed locally. About 6k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

TDD with Vitest and TypeScript Guide Claude through Test-Driven Development workflows using Vitest and TypeScript. Core TDD Cycle: Red-Green-Refactor Always follow this three-phase cycle: 1. Red: Write a failing test that defines desired behavior 2. Green: Write minimal code to make the test pass 3. Refactor: Improve code quality while keeping tests green Workflow Pattern Vitest Setup and Configuration Basic Vitest Config Create vitest.config.ts: TypeScript Configuration Ensure tsconfig.json includes: Test File Organization Naming Conventions Test files: .test.ts or .spec.ts Place tests adjacent to source files or in tests directories Match test file names to source files: calculator.ts → calculator.test.ts Structure Pattern TypeScript Testing Patterns Type-Safe Test Data Testing Generic Functions Testing Async/Promise Code Mocking and Stubbing Module Mocks Function Spies Partial Mocks Common Testing Patterns Testing Classes Testing Pure Functions Testing Error Handling Parametric Tests Test Coverage Guidelines Running Coverage Coverage Targets Aim for 80%+ coverage on business logic 100% coverage on critical paths (authentication, payments, etc.) Don't obsess over 100% everywhere—focus on meaningful tests What to Test Always test: Business logic and domain rules Error handling and edge cases Public APIs and interfaces Data transformations Consider skipping: Simple getters/setters Framework/library code Trivial type definitions Configuration files TDD Best Practices Write Tests First Always start with the test, not the implementation: One Assertion Per Test Keep tests focused: Test Behavior, Not Implementation Keep Tests Fast Use mocks for external dependencies (databases, APIs, file system) Avoid sleep/setTimeout in tests Run expensive setup once with beforeAll when safe Descriptive Test Names Common TDD Workflow Starting a New Feature 1. Write a high-level test describing the feature: 2. Run test → See it fail (Red) 3. …

How to use it

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

@skills aiskillstore/tdd-vitest-typescript

View the source on GitHub

Browse the @skills marketplace