Skip to main content
skill CX Codex

unit-testing-framework — Claude Code skill: unit tests, AAA style

A skill that gives the agent rules for writing unit tests: Arrange-Act-Assert structure, mocks, edge cases. Useful when a function or class needs coverage.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aj-geddes/useful-ai-prompts --skill unit-testing-framework -a claude-code
Open on GitHub

What unit-testing-framework does

The skill spells out how to write unit tests: one assertion per test, names that describe behaviour, external dependencies replaced with mocks. Inside there is a walkthrough of the AAA pattern on a JavaScript example with Jest, a table of reference guides in the references/ directory, and a do/don't list of practices.

The guides cover test structure, examples across languages, mocks and test doubles, async code and coverage, edge cases, and a complete test suite. The don't list is blunt about it: no tests that depend on each other, no assertions on implementation details, no real databases or APIs inside a unit test.

The skill is not tied to one framework — Jest, pytest, JUnit and RSpec all appear in the description. If your project already has its own test conventions, the agent will push them toward AAA and mocks, so it is worth comparing styles before installing.

What it helps with

  • write tests for a new function or class
  • raise coverage on critical code paths
  • set one test style across a team
  • refactor code with tests as a safety net
  • work out how to mock external dependencies

Example prompts for the agent

  • write unit tests for UserService.createUser using the AAA pattern
  • add edge case tests for the discount calculation function
  • refactor this module, write the tests first

How to install unit-testing-framework

1Skills CLI (Vercel)

npx skills add aj-geddes/useful-ai-prompts --skill unit-testing-framework -a claude-code

2Manually: put the files in place

~/.claude/skills/unit-testing-framework/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/unit-testing-framework/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about unit-testing-framework

How do I install unit-testing-framework in Claude?

Run npx skills add aj-geddes/useful-ai-prompts --skill unit-testing-framework -a claude-code. The skill lands in ~/.claude/skills/unit-testing-framework/SKILL.md.

What does unit-testing-framework do?

It gives the agent rules for unit tests: the Arrange-Act-Assert pattern, isolated tests, mocks for external dependencies, and edge case checks. The guides in references/ cover test structure, examples across languages, and async code.

Which test frameworks does the skill cover?

Jest, pytest, JUnit and RSpec are named in the description. The quick start example is JavaScript with Jest.

Source text

SKILL.md · MIT
---
name: unit-testing-framework
description: >
  Write comprehensive unit tests with high coverage using testing frameworks
  like Jest, pytest, JUnit, or RSpec. Use when writing tests for functions,
  classes, components, or establishing testing standards.
---

# Unit Testing Framework

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## Overview

Write effective unit tests that are fast, isolated, readable, and maintainable following industry best practices and AAA (Arrange-Act-Assert) pattern.

## When to Use

- Writing tests for new code
- Improving test coverage
- Establishing testing standards
- Refactoring with test safety
- Implementing TDD (Test-Driven Development)
- Creating test utilities and mocks

## Quick Start

Minimal working example:

```javascript
// Jest/JavaScript example
describe("UserService", () => {
  describe("createUser", () => {
    it("should create user with valid data", async () => {
      // Arrange - Set up test data and dependencies
      const userData = {
        email: "[email protected]",
        firstName: "John",
        lastName: "Doe",
      };
      const mockDatabase = createMockDatabase();
      const service = new UserService(mockDatabase);

      // Act - Execute the function being tested
      const result = await service.createUser(userData);

      // Assert - Verify the outcome
      expect(result.id).toBeDefined();
      expect(result.email).toBe("[email protected]");
      expect(mockDatabase.save).toHaveBeenCalledWith(
        expect.objectContaining(userData),
      );
    });
  });
});
```

## Reference Guides

Detailed implementations in the `references/` directory:

| Guide | Contents |
|---|---|
| [Test Structure (AAA Pattern)](references/test-structure-aaa-pattern.md) | Test Structure (AAA Pattern) |
| [Test Cases by Language](references/test-cases-by-language.md) | Test Cases by Language |
| [Mocking & Test Doubles](references/mocking-test-doubles.md) | Mocking & Test Doubles |
| [Testing Async Code](references/testing-async-code.md) | Testing Async Code, Test Coverage |
| [Testing Edge Cases](references/testing-edge-cases.md) | Testing Edge Cases |
| [Example: Complete Test Suite](references/example-complete-test-suite.md) | import { UserService } from "./user-service"; |

## Best Practices

### ✅ DO

- Write tests before or alongside code (TDD)
- Test one thing per test
- Use descriptive test names
- Follow AAA pattern
- Test edge cases and error conditions
- Keep tests isolated and independent
- Use setup/teardown appropriately
- Mock external dependencies
- Aim for high coverage on critical paths
- Make tests fast (< 10ms each)
- Use parameterized tests for similar cases
- Test public interfaces, not implementation

### ❌ DON'T

- Test implementation details
- Write tests that depend on each other
- Ignore failing tests
- Test third-party library code
- Use real databases/APIs in unit tests
- Make tests too complex
- Skip edge cases
- Forget to clean up resources
- Test everything (focus on business logic)
- Write flaky tests

© aj-geddes · MIT · aj-geddes/useful-ai-prompts

Similar skills

Everything for Testing and QA →

From the same set118

competitor-analysis A skill that walks the agent through competitor research: direct and indirect players, a comparison matrix, SWOT, and a findings report. Useful before pricing or positioning calls. CX Codex +1 603installs security-testing Flags security flaws in code and dependencies, tests against OWASP Top 10 risks, and guides DAST scanning via OWASP ZAP. CX Codex +1 601installs frontend-accessibility This skill adds WCAG guidelines to your coding workflow. It instructs agents to write semantic HTML, configure ARIA attributes, and support keyboard navigation. CX Codex +1 599installs design-patterns-implementation Guides the agent toward the right pattern for an architectural problem: Singleton, Factory, Observer, Strategy and more. Useful during refactoring or code review. CX Codex +1 595installs database-query-optimization A skill that walks your agent through slow SQL: execution plans, indexes, and where the time actually goes. Useful when the database drags. CX Codex +1 586installs database-backup-restore A coding assistant skill for backup and disaster recovery strategies. Use it when planning backups, testing restore procedures, or setting up automated backup jobs. CX Codex +1 582installs memory-leak-detection A skill for tracking down memory leaks: heap snapshots, profiling and the usual patterns behind growing memory use. CX Codex +1 580installs technical-roadmap-planning Builds a technical roadmap across quarters and years: architecture, infrastructure, stack investments. Useful before a big modernization push. CX Codex +1 577installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor