testing-patterns

testing-patterns is a skill for Claude Code, Codex from mickeyyaya/refactoring-skills. It costs 48 tokens per session (1,528 once invoked), scanned A, original, MIT.

A testing guide that explains test doubles, common test problems, testing strategies, and TDD anti-patterns. TDD means writing a failing test before the implementation and then making it pass.

In plain words
What is it for?
Use it when writing, reviewing, or diagnosing tests, including decisions about mocks, stubs, spies, fakes, and test structure.
Why use it?
It helps distinguish useful tests from slow, fragile, misleading, or overly coupled test suites.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing, reviewing, or diagnosing tests, including decisions about mocks, stubs, spies, fakes, and test structure.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mickeyyaya/refactoring-skills/testing-patterns
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.

Any agent
npx skills add mickeyyaya/refactoring-skills --skill testing-patterns
Clone the repo
git clone --depth 1 https://github.com/mickeyyaya/refactoring-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for testing-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/testing-patterns/github.svg)](https://agentmods.dev/skills/mickeyyaya/refactoring-skills/testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/testing-patterns"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/testing-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for testing-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/testing-patterns"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/testing-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,528 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00048 $0.01528
Opus 5 $0.00024 $0.00764
Sonnet 5 $0.00010 $0.00306
Haiku 4.5 $0.00005 $0.00153

Measured 9d ago against content hash 0d65af20f551, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, 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 9d 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/testing-patterns/SKILL.md · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing Patterns and Anti-Patterns

Overview

Classify test doubles, recognize test smells, apply testing strategies, and avoid TDD anti-patterns. Use when writing tests, reviewing test coverage in a PR, or diagnosing slow/fragile/misleading test suites.


Test Double Taxonomy

Google's preference order: Real > Fake > Stub > Mock

Double What it does Verifies calls? Has logic? Use when
Dummy Passed but never used No No Satisfying unused required params
Stub Returns preset values No Minimal Controlling outputs for a specific path
Spy Records calls, delegates to real Yes (after) Yes Verifying call count/args without replacing behavior
Mock Pre-programmed expectations Yes (during) No Strict interaction verification — use sparingly
Fake Simplified working impl No Yes Replacing slow/external systems (in-memory DB, fake API)
// DUMMY
const dummyLogger: Logger = {} as Logger;

// STUB
const stubUserRepo = { findById: (_id: string) => Promise.resolve({ id: "1", name: "Alice" }) };

// SPY
const sendEmailSpy = jest.spyOn(emailService, "send");
await notifyUser(user);
expect(sendEmailSpy).toHaveBeenCalledWith(user.email, expect.any(String));

// MOCK
const mockGateway = { charge: jest.fn().mockResolvedValue({ status: "ok" }) };
await checkout(cart, mockGateway);
expect(mockGateway.charge).toHaveBeenCalledWith(cart.total);

// FAKE
class FakeUserRepository implements UserRepository {
  private store = new Map<string, User>();
  async findById(id: string) { return this.store.get(id) ?? null; }
  async save(user: User) { this.store.set(user.id, user); }
}

Test Smells

1. The Liar

Passes but does not verify claimed behavior. Assertions always evaluate to true.

// SMELL: expect(result).toBeDefined();  // FIX: expect(result).toBe(90);

2. Excessive Setup

50+ lines before first assertion. Unit under test has too many dependencies. Fix: Factory function accepting only test-relevant params.

Read the full file on GitHub · 169 lines

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. 9d ago First seen · 169 lines · 48 tokens per session scan A 0d65af20f551

Subscribe to this mod's changes

testing-patterns is a skill published in the GitHub repository mickeyyaya/refactoring-skills (6 stars, last pushed 5mo ago), licensed MIT. It adds 48 tokens to every session and 1,528 once invoked, about $0.0002 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-09-03.