Agent skill · software engineering · yonatangross

testing-unit

Unit test patterns: AAA, parametrized tests, fixture scope, MSW or VCR network mocks, data factories, for Vitest, Jest and pytest. Use when writing unit tests or setting up mocks and fixtures.

Why this skill is useful

Provides specific patterns and scripts for unit testing that enhance the AI's ability to generate effective test cases and manage test data.

What it needs

Requires factoryboy, faker-js, msw, pytest, vcr, vitest installed locally. About 5k tokens when loaded. Last updated 2026-08-06. 215 stars on the source repository.

What this skill does

Unit Testing Patterns Focused patterns for writing isolated, fast, maintainable unit tests. Covers test structure (AAA), parametrization, fixture management, HTTP mocking (MSW/VCR), and test data generation with factories. Each category has individual rule files in rules/ loaded on-demand, plus reference material, checklists, and scaffolding scripts. Core Principles (ALWAYS apply) 1. AAA structure: Every test MUST follow Arrange-Act-Assert. Use // Arrange, // Act, // Assert comments for clarity. 2. Parametrize, don't duplicate: Use test.each (TypeScript) or @pytest.mark.parametrize (Python) when testing multiple inputs. Never copy-paste the same test body with different values. 3. Fixture scoping matters: Use scope="function" (default) for mutable data. Use scope="module" or scope="session" ONLY for expensive read-only resources (DB engines, ML models). Mutable data with shared scope causes flaky tests. 4. Speed target: Each unit test should run under 100ms. If it's slower, you're likely hitting I/O — mock it. 5. Mock at the network level: Use MSW (TypeScript) or VCR.py (Python) to intercept HTTP at the network layer. Never mock fetch/axios/requests directly. Quick Reference Category Rules Impact When to Use ---------- ------- -------- ------------- Unit Test Structure 3 CRITICAL Writing any unit test HTTP Mocking 2 HIGH Mocking API calls in frontend/backend tests Test Data Management 3 MEDIUM Setting up test data, factories, fixtures Total: 8 rules across 3 categories, 4 references, 3 checklists, 1 example set, 3 scripts Unit Test Structure Core patterns for structuring isolated unit tests with clear phases and efficient execution. …

How to use it

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

@skills yonatangross/testing-unit--ab55ed

View the source on GitHub

Browse the @skills marketplace