writing-tests

Write and review Vitest tests through interfaces, fakes, and behavior-driven assertions.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/tomada1114/quick-reply-drill --skill writing-tests-tomada1114
Or copy as Structured Prompt for Agentβ–Ό
Please help me install this Agent Skill.
Skill: writing-tests
Source: https://github.com/tomada1114/quick-reply-drill/tree/main/.agents/skills/writing-tests
Command: npx skills add https://github.com/tomada1114/quick-reply-drill --skill writing-tests-tomada1114

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Tests that mock internal collaborators, assert error message text, or recompute expected values the same way the implementation does break on every refactor and pass even when the code is wrong. This Skill codifies how to write Vitest tests that assert behavior through stable interfaces so they survive refactoring and actually catch bugs. ## Core Features & Use Cases - Interface-driven testing: Drive handler factories with real Request objects, render synchronous Server Components under jsdom with Testing Library, and run a shared LlmPort contract suite once per adapter. - Fakes over mocks: Replace real sleeps with vi.useFakeTimers, isolate filesystem tests in mkdtempSync temp directories, and prefer in-memory fakes like createFakeLlmPort over mocks of internal collaborators. - Rigorous assertions: Assert error classes and stable code fields instead of messages, source expected values from outside the implementation, and sweep edge cases with labelled it.each tables closed by as const satisfies. - Use Case: When fixing a bug in a Next.js route handler, write a regression test that builds a new Request, injects a fake port, and asserts the response status and JSON body β€” without mocking anything internal. ## Quick Start Ask the AI to write a Vitest test for a specific handler, page, or adapter following the writing-tests conventions for naming, fakes, and assertions.

Frequently Asked Questions about writing-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are common Vitest test anti-patterns to avoid in review?β–Ό

Avoid toBeDefined() where a specific value is checkable, recomputing expected values the way the implementation does, mocking so much that real code never runs, and leaving it.skip or flaky tests on main instead of fixing them.