aaa-pattern

Restructure unit tests into separate Arrange, Act, and Assert sections.

13|2|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/yanko-belov/code-craft --skill aaa-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aaa-pattern
Source: https://github.com/yanko-belov/code-craft/tree/main/skills/aaa-pattern
Command: npx skills add https://github.com/yanko-belov/code-craft --skill aaa-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tests often mix Arrange, Act, and Assert, making failures hard to diagnose and refactors risky. The AAA pattern enforces a clear, repeatable structure that isolates setup, action, and verification.

Core Features & Use Cases

  • Clear separation of test phases to improve readability and maintainability.
  • Guided refactoring by identifying when actions or assertions are intertwined.
  • Cross-framework applicability across popular testing frameworks (e.g., Jest, Mocha, PyTest) to standardize test quality.
  • Use Case: When a test contains multiple actions and assertions, convert it into distinct AAA sections to reduce cognitive load and speed debugging.

Quick Start

To start using AAA pattern in your tests, restructure an existing test by placing setup code under Arrange, the operation under Act, and the expected results under Assert, then rename the test to reflect the behavior being verified.

Frequently Asked Questions about aaa-pattern

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

FAQPage Schema
How do I fix unit tests that mix setup, actions, and assertions together?

The AAA pattern enforces a strict Arrange-Act-Assert structure to keep unit tests readable and debuggable. It requires a single Act per test, explicit test naming, and clear separation of Arrange, Act, and Assert stages to isolate setup, action, and verification.

What is the Arrange-Act-Assert pattern for unit test structure?

Arrange-Act-Assert is a testing structure that isolates setup, action, and verification into distinct sections. By enforcing a single Act per test and explicit naming, it creates a clear, repeatable format that makes test failures easier to diagnose and refactors less risky.

Does the AAA test structure work with Jest, Mocha, and PyTest frameworks?

Yes, the AAA pattern applies cross-framework across popular testing tools like Jest, Mocha, and PyTest. It standardizes unit test quality by enforcing a single Act per test and clear separation of Arrange, Act, and Assert stages regardless of the framework or language.

How do I refactor a test with multiple actions and assertions into distinct sections?

To refactor a test with multiple actions, place setup code under Arrange, the single operation under Act, and expected results under Assert. Converting intertwined actions into distinct AAA sections requires a single Act per test and explicit naming to reduce cognitive load and speed debugging.

When should I enforce a single Act per test in my unit tests?

Enforce a single Act per test when unit tests become unclear or mixed with multiple actions and assertions. This strict Arrange-Act-Assert separation isolates the operation, making test failures easier to diagnose and reducing the risk during code refactoring.