unit-testing

Installation
SKILL.md

Unit Testing — Testing Isolated Functions and Classes

Overview

Unit tests verify the smallest testable parts of an application in isolation. They are fast, cheap to run, and provide rapid feedback on whether individual functions, methods, and classes behave correctly. In the Test Trophy model, unit tests sit above static analysis and below integration tests.

When to unit test: Pure functions, business logic, algorithms, data transformations, edge cases, error handling, and any code with complex branching.

The AAA Pattern (Arrange-Act-Assert)

Every unit test should follow three distinct phases:

  1. Arrange — Set up test data, dependencies, and preconditions
  2. Act — Execute the function or method under test
  3. Assert — Verify the result matches expectations

AAA in TypeScript (Vitest)

import { describe, it, expect } from 'vitest';
import { calculateDiscount } from './pricing';
Installs
1
GitHub Stars
10
First Seen
2 days ago
unit-testing — tyler-r-kendrick/agent-skills