testing-patterns

A set of patterns for writing unit tests, which check one part of a program, and integration tests, which check several parts working together.

In plain words
What is it for?
Use it when testing user registration, authenticated pages, external service calls, and complete workflows such as checkout.
Why use it?
It gives tests a consistent structure and shows how to replace outside services, such as email systems, with test substitutes. This makes tests easier to read and less dependent on other systems.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/langchain-ai/skills-benchmarks/testing_patterns
Any agent
npx skills add langchain-ai/skills-benchmarks --skill testing_patterns
Clone the repo
git clone --depth 1 https://github.com/langchain-ai/skills-benchmarks

Made for: Claude Code, Codex.

Per session 11 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 394 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00011 $0.00394
Opus 5 $0.00005 $0.00197
Sonnet 5 $0.00002 $0.00079
Haiku 4.5 $0.00001 $0.00039

Measured 3d ago against content hash f73828a8c53c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/noise/testing_patterns/SKILL.md · 86 lines

What it actually says

Testing Patterns

Write effective, maintainable tests using modern patterns.

Test Structure (AAA Pattern)

def test_user_registration():
    # Arrange
    user_data = {"email": "[email protected]", "password": "secure123"}

    # Act
    result = register_user(user_data)

    # Assert
    assert result.success is True
    assert result.user.email == "[email protected]"

Mocking External Services

from unittest.mock import Mock, patch

@patch('services.email.send_email')
def test_sends_welcome_email(mock_send):
    mock_send.return_value = True

    register_user({"email": "[email protected]"})

    mock_send.assert_called_once_with(
        to="[email protected]",
        template="welcome"
    )

Fixtures and Factories

import pytest
from factories import UserFactory

@pytest.fixture
def user():
    return UserFactory.create(role="admin")

@pytest.fixture
def authenticated_client(user):
    client = TestClient(app)
    client.login(user)
    return client

def test_admin_dashboard(authenticated_client):
    response = authenticated_client.get("/admin")
    assert response.status_code == 200

Integration Tests

@pytest.mark.integration
def test_full_checkout_flow(db_session, stripe_mock):
    # Create test data
    user = create_user()
    product = create_product(price=100)

    # Execute flow
    cart = add_to_cart(user, product)
    order = checkout(cart, payment_method="card")

    # Verify
    assert order.status == "completed"
    assert stripe_mock.charges.create.called

Test Coverage Goals

  • Unit tests: 80%+ coverage
  • Integration tests: Critical paths
  • E2E tests: Happy paths only
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 86 lines · 11 tokens per session scan A f73828a8c53c

Subscribe to this mod's changes

testing-patterns is a skill published in the GitHub repository langchain-ai/skills-benchmarks (116 stars, last pushed 15d ago), licensed MIT. It adds 11 tokens to every session and 394 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.