502
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill citypaul/.dotfiles --skill testing- SKILL.md10.9 KB
Overview
This skill provides concise patterns for behavior-driven testing and test factory design. It focuses on testing public behavior rather than implementation details, ensuring tests remain valuable across refactors. Use these principles to get meaningful coverage and maintainable test suites.
How this skill works
The skill teaches testing through the public API: write tests that assert observable outcomes and edge cases instead of spying on internals or private methods. It prescribes factory functions that produce complete, schema-validated test data with Partial<T> overrides and encourages composing factories for nested objects. It also highlights anti-patterns that create false coverage and shows how to replace them with behavior-focused tests.
When to use it
- Writing unit or integration tests where behavior matters more than implementation
- Creating test data and factories for repeatable, isolated tests
- Refactoring code while keeping tests stable and meaningful
- Diagnosing sudden coverage drops to find untested business behavior
- Designing test suites to avoid brittle, implementation-coupled assertions
Best practices
- Test through the public API only — assert outcomes, not calls or internal flags
- Use factory functions that return complete objects with sensible defaults
- Validate factory output with real production schemas to catch breaking changes early
- Accept Partial<T> overrides for easy customization and fresh state per test
- Avoid shared mutable state — prefer one factory call per test instead of let/beforeEach
- Cover branches and edge cases, not just the happy path
Example use cases
- Process-payment tests that assert success/failure and error messages instead of spying on validators
- Factories for users, orders, and items composed to build complex test objects reliably
- Detecting coverage theater by replacing call-count assertions with outcome assertions
- Refactoring validators or processors without changing tests because tests target behavior
- Writing tests that validate schema changes by failing when factories no longer produce valid data
FAQ
Private methods and internal flags are implementation details. Testing them makes tests brittle and forces changes whenever you refactor internal structure. Test the behavior exposed by the public API instead.
How do factories help with test isolation?
Factories create fresh, complete objects per test, removing shared mutable state and eliminating the need for let/beforeEach. Using Partial<T> overrides makes customization simple while keeping defaults consistent.