test-writer

A guide for generating Vitest tests for JavaScript examples in concept documentation. Vitest is a JavaScript testing tool used to run automated checks.

In plain words
What is it for?
Use it after writing or editing a concept page to extract its examples, test runnable and DOM-based code, check expected errors, and document snippets that cannot be tested.
Why use it?
It helps catch examples whose output, errors, browser behavior, or documented claims do not match what the code actually does.

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/leonardomso/33-js-concepts/test-writer
Any agent
npx skills add leonardomso/33-js-concepts --skill test-writer
Clone the repo
git clone --depth 1 https://github.com/leonardomso/33-js-concepts

Made for: Claude Code, Codex.

Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,390 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.00026 $0.05390
Opus 5 $0.00013 $0.02695
Sonnet 5 $0.00005 $0.01078
Haiku 4.5 $0.00003 $0.00539

Measured yesterday against content hash 76dda6fa2dd6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-writer 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 yesterday.

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.

.claude/skills/test-writer/SKILL.md · 941 lines

How it starts

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

Skill: Test Writer for Concept Pages

Use this skill to generate comprehensive Vitest tests for all code examples in a concept documentation page. Tests verify that code examples in the documentation are accurate and work as described.

When to Use

  • After writing a new concept page
  • When adding new code examples to existing pages
  • When updating existing code examples
  • To verify documentation accuracy through automated tests
  • Before publishing to ensure all examples work correctly

Test Writing Methodology

Follow these four phases to create comprehensive tests for a concept page.

Phase 1: Code Example Extraction

Scan the concept page for all code examples and categorize them:

Category Characteristics Action
Testable Has console.log with output comments, returns values Write tests
DOM-specific Uses document, window, DOM APIs, event handlers Write DOM tests (separate file)
Error examples Intentionally throws errors, demonstrates failures Write tests with toThrow
Conceptual ASCII diagrams, pseudo-code, incomplete snippets Skip (document why)
Browser-only Uses browser APIs not available in jsdom Skip or mock

Phase 2: Determine Test File Structure

tests/
├── fundamentals/              # Concepts 1-6
├── functions-execution/       # Concepts 7-8
├── web-platform/             # Concepts 9-10
├── object-oriented/          # Concepts 11-15
├── functional-programming/   # Concepts 16-19
├── async-javascript/         # Concepts 20-22
├── advanced-topics/          # Concepts 23-31
└── beyond/                   # Extended concepts
    └── {subcategory}/

File naming:

  • Standard tests: {concept-name}.test.js
  • DOM tests: {concept-name}.dom.test.js

Phase 3: Convert Examples to Tests

For each testable code example:

  1. Identify the expected output (from console.log comments or documented behavior)
  2. Convert to expect assertions
  3. Add source line reference in comments
  4. Group related tests in describe blocks matching documentation sections

Read the full file on GitHub · 941 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. yesterday First seen · 941 lines · 26 tokens per session scan A 76dda6fa2dd6

Subscribe to this mod's changes

test-writer is a skill published in the GitHub repository leonardomso/33-js-concepts (66,520 stars, last pushed 29d ago), licensed MIT. It adds 26 tokens to every session and 5,390 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.