- Home
- Skills
- Yanko Belov
- Code Craft
- Aaa Pattern
aaa-pattern_skill
- TypeScript
6
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 yanko-belov/code-craft --skill aaa-pattern- SKILL.md5.4 KB
Overview
This skill enforces the Arrange-Act-Assert (AAA) pattern for tests. It helps you detect and fix mixed phases so tests remain readable, maintainable, and debuggable. Use it when test structure or intent is unclear.
How this skill works
The skill inspects test code for interleaved setup, actions, and assertions. It flags smells like expect() calls between actions, multiple acts in one test, or assertions scattered throughout. It then recommends restructuring tests into explicit Arrange, Act, and Assert sections, and suggests splitting tests when multiple behaviors are mixed.
When to use it
- Writing any unit or integration test
- Test logic is hard to follow or name
- You see assertions between actions
- Multiple actions or behaviors are combined in one test
- Enforcing consistent test style across a codebase
Best practices
- Always separate Arrange, Act, and Assert in that order
- Keep Act to a single behavior; move repeated setup into Arrange
- Use comments or section breaks to make phases explicit
- Allow multiple asserts only when they verify one logical behavior
- If you need multiple acts, create separate tests
Example use cases
- Refactor a failing test where assertions are sprinkled between operations
- Review new tests in a pull request for mixed phase smells
- Write clear BDD-style tests using Given-When-Then mapped to AAA
- Enforce consistent test layout in a shared TypeScript test suite
- Educate teammates by converting messy tests into explicit AAA examples
FAQ
Yes. Consistency matters: use AAA even for simple tests to keep structure uniform across the suite.
Can a test have multiple assertions?
Yes, as long as all assertions verify a single logical behavior. Multiple behaviors require multiple tests.