cleanup-unit-tests

Diagnoses failing unit tests and applies fixes to mocks, assertions, and snapshots.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code changes often break existing unit tests, leaving developers to manually triage failures across mocks, assertions, factories, and snapshots. This Skill automates the diagnosis and repair of broken tests while flagging structural problems that need human judgment. ## Core Features & Use Cases - Failure Diagnosis: Runs the test suite, groups failures by file, and categorizes each one (stale mock, outdated assertion, missing factory field, stale snapshot, changed import). - Convention-Aware Fixes: Loads repo test patterns via the test-context tool so fixes match existing mock and assertion styles instead of introducing inconsistencies. - Human Escalation: Surfaces structural test architecture issues for review rather than guessing, and refuses to suppress errors with ts-ignore or weakened assertions. - Use Case: After refactoring a service interface, run this Skill to update all affected mocks and assertions, regenerate intentional snapshot changes, and receive a report of what was fixed versus what needs a human decision. ## Quick Start Fix the unit tests that are failing after my recent changes to the user service.

Frequently Asked Questions about cleanup-unit-tests

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

FAQPage Schema
How do I fix failing unit tests after a code change?

Run the test suite to capture failures, then categorize each one: stale mocks, outdated assertions, missing factory fields, or old snapshots. Apply fixes that match the repo's existing test conventions, and re-run until all fixable failures pass.

How to update mocks when an interface changes in tests?

Add the new method or property to the mock so it matches the real interface, following how other tests in the same file mock that dependency. Avoid mocking the function differently than the established file pattern.

When should I update a snapshot versus fix the code?

Update a snapshot only when the output change is intentional and verified. If the snapshot diff reveals unexpected behavior, treat it as a code regression and investigate the source change instead of blindly regenerating.

Can I scope test fixes to a single file or package?

Yes, pass a path to a specific test file or package as an argument, and only that scope runs via pnpm test. Without an argument, the full unit test suite runs and all failures are triaged.

What test failures should not be auto-fixed?

Structural issues where the test architecture itself is wrong should be surfaced for human review rather than guessed at. Fixes that suppress errors with ts-ignore, any casts, or removed assertions should also be avoided.