testing-patterns

testing-patterns is a skill for Claude Code, Codex from 0xMassi/claude-skills. It costs 54 tokens per session (4,433 once invoked), scanned C, original, MIT.

A collection of testing rules for TypeScript, Rust, Swift, and Go projects, covering test files, mocks, asynchronous code, and continuous integration.

In plain words
What is it for?
It guides unit, end-to-end, and live tests; Vitest configuration; mock behavior; async tests; and test commands used in CI.
Why use it?
It helps developers choose consistent test structures and avoid common testing mistakes across different programming languages.

Skill for Claude CodeCodex

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

Good fit It guides unit, end-to-end, and live tests; Vitest configuration; mock behavior; async tests; and test commands used in CI.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/0xmassi/claude-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 0xMassi/claude-skills --skill testing-patterns
Clone the repo
git clone --depth 1 https://github.com/0xMassi/claude-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/0xmassi/claude-skills/testing-patterns/github.svg)](https://agentmods.dev/skills/0xmassi/claude-skills/testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/0xmassi/claude-skills/testing-patterns"><img src="https://agentmods.dev/badge/skills/0xmassi/claude-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/0xmassi/claude-skills/testing-patterns"><img src="https://agentmods.dev/badge/skills/0xmassi/claude-skills/testing-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,433 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00054 $0.04433
Opus 5.5 $0.00022 $0.01773
Sonnet 5.5 $0.00011 $0.00887
Haiku 4.5 $0.00005 $0.00443

Measured 1mo ago against content hash 1a4173b1df4d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

testing-patterns scanned grade C with 1 finding 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 1mo 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

expect(prompt).toHaveBeenCalledWith("exec", "exec: rm -rf /");
testing-patterns/SKILL.md · 535 lines

How it starts

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

Testing Patterns

TypeScript / JavaScript Testing (Vitest)

File Conventions

  • Colocated tests: src/foo.test.ts next to src/foo.ts (primary pattern)
  • E2E tests: *.e2e.test.ts in test/ directory or colocated
  • Live tests: *.live.test.ts for tests requiring real API keys
  • Setup file: test/setup.ts for global beforeEach/afterEach hooks
  • Config layering: base vitest.config.ts extended by vitest.unit.config.ts, vitest.e2e.config.ts, vitest.live.config.ts

Test Structure

import { describe, expect, it, vi } from "vitest";

describe("resolvePermission", () => {
  it("auto-approves safe tools without prompting", async () => {
    const prompt = vi.fn(async () => true);
    const res = await resolvePermission(makeRequest(), { prompt });
    expect(res).toEqual({ outcome: "allow" });
    expect(prompt).not.toHaveBeenCalled();
  });

  it("prompts for dangerous operations", async () => {
    const prompt = vi.fn(async () => true);
    await resolvePermission(makeDangerousRequest(), { prompt });
    expect(prompt).toHaveBeenCalledTimes(1);
    expect(prompt).toHaveBeenCalledWith("exec", "exec: rm -rf /");
  });
});

Mock Patterns

// Function mocks for dependency injection
const sendFn = vi.fn(async () => ({ messageId: "test" }));

// Module mocks (use sparingly -- prefer DI)
vi.mock("./network.js", () => ({
  fetch: vi.fn().mockResolvedValue({ ok: true }),
}));

// Spy on existing methods
const spy = vi.spyOn(store, "save");
expect(spy).toHaveBeenCalledWith(expectedData);

// Stub environment variables (auto-cleaned with unstubEnvs: true)
vi.stubEnv("API_KEY", "test-key-123");

// Fake timers (guard against leaks in afterEach)
vi.useFakeTimers();
vi.advanceTimersByTime(5000);
// Always restore: vi.useRealTimers()

Test Setup Pattern (Global)

// test/setup.ts
import { afterAll, afterEach, beforeEach, vi } from "vitest";
import { withIsolatedTestHome } from "./test-env.js";

process.env.VITEST = "true";
const testEnv = withIsolatedTestHome(); // Isolated HOME per worker
afterAll(() => testEnv.cleanup());

afterEach(() => {
  if (vi.isFakeTimers()) vi.useRealTimers(); // Prevent cross-test leaks
});

Read the full file on GitHub · 535 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. 1mo ago First seen · 535 lines · 54 tokens per session scan C 1a4173b1df4d

Subscribe to this mod's changes

testing-patterns is a skill published in the GitHub repository 0xMassi/claude-skills (8 stars, last pushed 6mo ago), licensed MIT. It adds 54 tokens to every session and 4,433 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

qa-testing

Run QA testing on a page, feature, or full site at one of three depth tiers (smoke, standard, full). Use this skill whenever the user asks to QA a page or site, run a smoke test after a deploy, verify a page before launch, or run a regression sweep. Triggers on QA, QA sweep, smoke test, regression test, post-deploy…

rampstackco/claude-skills · 170 tokens

visual-qa

Runs rigorous visual QA across web, terminal, and paginated surfaces: an Apple HIG-based checklist, paired light/dark captures at phone and desktop widths, screenshot evidence, and a per-item PASS/FAIL verdict. Use for any UI build or change, or when asked whether a page, component, or TUI looks right or follows the…

code-yeongyu/oh-my-openagent · 78 tokens

remove-ai-slops

Removes AI-generated code smells from branch changes or an explicit file list behind regression tests. Use when the user asks to clean up, deslop, or remove AI-slop patterns from recent changes.

code-yeongyu/oh-my-openagent · 45 tokens

senpi-qa

QA the omo Senpi adapter (packages/omo-senpi, packages/senpi-task) against the REAL senpi binary in strict isolation, and write every artifact to the one canonical evidence path .omo/evidence/omo-senpi-adapter/ /. The live drivers under packages/omo-senpi/scripts/qa/ create their own isolated SENPICODINGAGENTDIR and…

code-yeongyu/oh-my-openagent · 251 tokens

test-coverage-improver

Analyze test coverage gaps and generate tests to improve coverage. Use when improving test coverage, finding untested code, or writing missing tests.

OneWave-AI/claude-skills · 34 tokens

browser-test-loop

Use to actually verify a web change in a real browser instead of assuming it works — click through a flow, catch console errors, check a form submits, confirm a fix on the page. Trigger when a UI change needs proof, a bug only reproduces in the browser, or the user asks to test, check, or screenshot the running app.

OneWave-AI/claude-skills · 74 tokens