write-unit-tests

Writes unit tests for components, hooks, and utilities following repo test conventions.

Updated Apr 9, 2026
One-click install
npx skills add https://github.com/muselesscreator/ui-skills --skill write-unit-tests-muselesscreator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-unit-tests
Source: https://github.com/muselesscreator/ui-skills/tree/main/write-unit-tests
Command: npx skills add https://github.com/muselesscreator/ui-skills --skill write-unit-tests-muselesscreator

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing unit tests that match a project's established conventions is slow and error-prone: you must discover the repo's test patterns, mock styles, and fixture practices before writing a single assertion. This Skill automates that discovery and produces tests covering happy paths, edge cases, and error states in the project's own style. ## Core Features & Use Cases - Repo-aware test generation: Loads structured test conventions via a test-context step, then writes tests using the project's existing naming, mock patterns, factories, and assertion style. - Coverage planning and verification: Builds an explicit test plan (happy path, edge cases, error states), runs the new test file with pnpm, and proves each test can fail by mutating the source and re-running. - Grounded fixtures: Requires enumerated or generated fixture values to be quoted from real production sources rather than invented. - Use Case: After adding a new React hook, invoke the Skill with the hook's path to get a test file that matches the repo's conventions, verified to run and to fail when its subject is broken. ## Quick Start Ask the AI to write unit tests for a specific file, for example: write unit tests for src/hooks/useCart.ts.

Frequently Asked Questions about write-unit-tests

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

FAQPage Schema
How do I write unit tests for a React hook or component?

Provide the file path of the hook or component and the Skill loads the repo's test conventions, plans coverage for happy paths, edge cases, and error states, then writes tests using the project's existing mock and fixture patterns.

How to add test coverage that matches an existing codebase style?

The Skill calls a test-context step that outputs the repo's structured test conventions, then reads existing test files before writing. New tests reuse the established naming, placement, factories, and assertion style rather than invented patterns.

Does it work with existing test files for the same component?

Yes. It searches for an existing test file matching the target's basename and reads it first. It then identifies missing coverage instead of replacing or duplicating tests that already exist.

Why should tests be verified by making them fail?

A test that still passes when its subject is broken provides no real coverage. The Skill neutralizes each guard or predicate in the source, re-runs the suite to confirm the expected failure, then restores the code and reports the mutation result.

What are the limitations of automated unit test generation?

It deliberately avoids testing framework behavior, trivial getters, and TypeScript-enforced invariants. Fixture values for enums or generated domain data must come from real production sources; if a literal never appears in the codebase, the code under test is flagged rather than accommodated.