testing

testing is a skill for Claude Code, Codex from gotgenes/pi-anthropic-auth. It costs 36 tokens per session (4,328 once invoked), scanned A, original, MIT.

A testing guide for Vitest, a JavaScript and TypeScript test framework, with mock patterns and general test-planning rules. Test-driven development, or TDD, means writing tests as part of the design process before or alongside code.

In plain words
What is it for?
Use it when planning, writing, or debugging tests and when configuring Vitest mocks such as vi.mock, vi.fn, vi.spyOn, and vi.hoisted.
Why use it?
It helps avoid common mock setup errors, especially around reset behavior, hoisting, constructors, and built-in modules.

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/gotgenes/pi-anthropic-auth/testing
Any agent
npx skills add gotgenes/pi-anthropic-auth --skill testing
Clone the repo
git clone --depth 1 https://github.com/gotgenes/pi-anthropic-auth

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/gotgenes/pi-anthropic-auth/testing.svg)](https://agentmods.dev/skills/gotgenes/pi-anthropic-auth/testing)
Your own site
<a href="https://agentmods.dev/skills/gotgenes/pi-anthropic-auth/testing"><img src="https://agentmods.dev/badge/skills/gotgenes/pi-anthropic-auth/testing.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,328 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.00036 $0.04328
Opus 5 $0.00018 $0.02164
Sonnet 5 $0.00007 $0.00866
Haiku 4.5 $0.00004 $0.00433

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

Security

Grade A, and why

testing 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.

.pi/skills/testing/SKILL.md · 174 lines

How it starts

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

Testing

Load this skill when writing, debugging, or planning tests.

Vitest mock patterns

vi.mock and hoisting

  • When using vi.mock(), extract each vi.fn() stub to a module-scope variable and reset it in beforeEachvi.restoreAllMocks() only operates on vi.spyOn() spies, not on vi.fn() instances. Use .mockReset() when the stub has no default implementation. Use .mockClear() when the vi.mock() factory provides a default implementation that tests must preserve.
  • When a vi.mock() factory references a module-scope vi.fn() stub, wrap the stub declaration in vi.hoisted() — Vitest hoists vi.mock() above normal declarations, so unhoisted variables are undefined when the factory runs.
  • When mocking a class constructor with vi.mock(), use vi.fn() with no implementation — not vi.fn(() => ({})). Arrow-function implementations are not constructable; new MockClass() throws "is not a constructor".
  • When mocking node:* built-in modules with vi.mock(), include a default key mirroring the named exports — omitting it causes "No default export defined on the mock" errors.
  • A vi.mock("node:*") factory that returns an object literal replaces the module: every export it omits becomes undefined, so a later call to a sibling export (lstatSync, tmpdir) throws TypeError in unrelated tests in that file. To stub one export and keep the rest, spread await vi.importActual<typeof import("node:fs")>("node:fs") in the factory and override only the target.
  • Import the module-under-test with a static top-level import, not a per-test await import(...) — Vitest hoists vi.mock()/vi.hoisted() above static imports, so the mock still applies. A per-test dynamic import of a module that transitively pulls heavy deps pays the transform/resolve cost inside each test's testTimeout window and can flake CI.

Typing mock functions

  • When a vi.fn() factory returns an empty array or narrow literal, annotate its return type explicitly — vi.fn((): string[] => []), not vi.fn(() => []). Without the annotation TypeScript infers never[], and subsequent mockReturnValueOnce([...]) calls fail with “not assignable to never”. Use import type to pull domain types (e.g., AgentConfig, PreloadedSkill) for the annotation.
  • When typing a mock field on an interface, use Mock<specific-signature> — e.g., Mock<() => void>, Mock<(arg: string) => Promise<void>>. Do not use ReturnType<typeof vi.fn> — in Vitest v4 it expands to Mock<Procedure | Constructable>, a union that TypeScript cannot call.

Read the full file on GitHub · 174 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. 3d ago First seen · 174 lines · 36 tokens per session scan A e211a2cf2bc8

Subscribe to this mod's changes

testing is a skill published in the GitHub repository gotgenes/pi-anthropic-auth (227 stars, last pushed 16d ago), licensed MIT. It adds 36 tokens to every session and 4,328 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-08-30.

Related

Other skills, from other repositories

surf

Control Chrome browser via CLI for testing, automation, and debugging. Use when the user needs browser automation, screenshots, form filling, page inspection, network/CPU emulation, DevTools streaming, or AI queries via ChatGPT/Gemini/Perplexity/Grok/AI Studio.

w-winter/dot314 · 60 tokens

prose-review

Review prose written for others -- user-facing docs, prompts for other LLMs, inline comments, docstrings, and other-facing messages -- for local jargon leakage, orphaned references, missing grounding, and audience or genre misfit.

w-winter/dot314 · 50 tokens

text-search

Search indexed text corpora with qmd. For indexed content, prefer qmd over grep.

w-winter/dot314 · 22 tokens

repoprompt-tool-guidance-refresh

Refresh RepoPrompt tool guidance when the CLI/MCP surface changes. Tracks RepoPrompt CE (rpce-cli, the maintained target) across versions, and can diff the frozen Classic CLI (rp-cli) against CE. Uses /.pi/agent/skills/repoprompt-tool-guidance-refresh/scripts/track-rp-version.sh to capture/diff --help and -l (tool…

w-winter/dot314 · 115 tokens

pi-commandcode-release

Use when preparing, validating, publishing, or documenting a pi-commandcode-provider release/deployment, including version bumps, changelog entries, npm publish, GitHub releases, tags, and release follow-up comments.

patlux/pi-commandcode-provider · 47 tokens

xcodebuildmcp

Build/test Xcode projects via the XcodeBuildMCP MCP server using a local CLI wrapper for pi (no MCP support). Use when the user mentions Xcode, xcodebuild, iOS builds/tests, or XcodeBuildMCP.

w-winter/dot314 · 56 tokens