unit-test-generator

Generates unit tests with AAA pattern, edge cases, and coverage analysis for TypeScript code.

2|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/sathishssj3/NexVR-Engine --skill unit-test-generator-sathishssj3
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: unit-test-generator
Source: https://github.com/sathishssj3/NexVR-Engine/tree/main/.agents/skills/unit-test-generator
Command: npx skills add https://github.com/sathishssj3/NexVR-Engine --skill unit-test-generator-sathishssj3

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing thorough unit tests by hand is repetitive and often skips edge cases and error scenarios, leaving code under-tested and fragile. ## Core Features & Use Cases - AAA Pattern Test Suites: Generates tests structured with Arrange-Act-Assert, covering happy paths, edge cases, and error cases. - Broad Test Type Support: Produces tests for plain functions, async services with mocked fetch calls, classes, and React components using Testing Library. - Coverage Documentation: Adds coverage notes tracking line, branch, function, and statement targets, plus a mirrored test file structure matching the source tree. - Use Case: Given a TypeScript utility like an email validator, generate a complete Vitest suite covering valid inputs, null/undefined/empty strings, and malformed formats in one pass. ## Quick Start Generate a comprehensive unit test suite with edge cases and error scenarios for my src/utils/validator.ts file using Vitest.

Frequently Asked Questions about unit-test-generator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate unit tests with the AAA pattern?▼

Structure each test into Arrange (set up inputs), Act (call the function), and Assert (verify the result). Group tests with describe blocks for happy path, edge cases, and error cases to keep suites organized and readable.

How to test async functions with mocked fetch in Vitest?▼

Replace global.fetch with vi.fn() in beforeEach, then use mockResolvedValueOnce for successful responses and mockRejectedValueOnce for network errors. Assert results with await and rejects.toThrow for error paths.

What edge cases should unit tests cover?▼

Cover null and undefined inputs, empty strings, whitespace-only values, zero and negative-zero numbers, very large values like Number.MAX_SAFE_INTEGER, and boundary conditions such as division by zero.

Does this approach work with React component testing?▼

Yes, it uses @testing-library/react with render, screen, and fireEvent to verify initial rendering, user interactions like button clicks, and state changes such as counters incrementing or resetting.

Why should tests avoid shared state between cases?▼

Shared state causes order-dependent failures and flaky tests. Use beforeEach to create fresh instances, like a new ShoppingCart per test, and reset mocks with vi.resetAllMocks in afterEach.