Vitest Standard
SkillSearchComprehensive unit testing expertise covering Vitest, test-driven development (TDD), mocking strategies, and production-grade best practices. Activates ONLY for unit testing scope (unit tests, integration tests, Vitest, TDD, Red-Green-Refactor, mocking, stubbing, spying, test coverage, and test architecture in TypeScript/Node projects). NOT for E2E testing (use Playwright). If the user asks to "write tests" without specifying the type, you MUST ask "Unit, E2E, or both?" before proceeding.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the Vitest Standard skill
What this skill tells your AI
The instructions your AI receives, as published by neverinfamous/memory-journal-mcp in skills/vitest-standard/SKILL.md and read by ahel’s review.
This skill provides opinionated, production-tested guidance for high-integrity unit testing with Vitest. It emphasizes behavior-driven design, strictly isolated tests, and the TDD lifecycle.
Golden Rules (Mandatory)
- Test Behavior, Not Implementation — Assert what the code does, not how it looks internally.
- Strict Isolation — NO shared state between tests. Create new instances in
beforeEach. - Clean Mocks — Use
vi.clearAllMocks()inbeforeEachto prevent call history leaks. - No Magic Numbers — Use descriptive variables for expected values.
- AAA Pattern — Every test must follow Arrange-Act-Assert.
- Async/Await — Always await promises; use
rejects.toThrow()for error paths. - Deterministic Tests — No dependence on system time, environment variables, or randomness (mock them).
- Meaningful Names — Use
it('should [action] when [condition]')or Given-When-Then. - Mock at Boundaries — Mock external APIs, databases, and third-party SDKs; test your own logic.
- Red-Green-Refactor — Prefer writing tests before code to drive API design.
- Security — Use fake/mock credentials in all tests — never real API keys, tokens, or passwords. Load sensitive test config from
.env.test.local(gitignored).
Core Patterns
AAA (Arrange-Act-Assert)
it('should calculate total price', () => {
// Arrange: Setup data and environment
const cart = new ShoppingCart()
cart.addItem({ price: 10, quantity: 2 })
// Act: Execute the method being tested
const total = cart.getTotal()
// Assert: Verify the outcome
expect(total).toBe(20)
})
Mocking Example
import { vi, it, expect } from 'vitest'
it('mocks dependencies', () => {
const mockFn = vi.fn().mockReturnValue(42)
expect(mockFn()).toBe(42)
expect(mockFn).toHaveBeenCalledOnce()
})
Quick Reference: Assertions
See assertions.md for a full list of Vitest assertions (toBe, toEqual, toThrow, etc.). This reference is auto-loaded only when writing test assertions.
Specialized References (Load On-Demand)
| Scenario | Reference File |
|---|---|
| Mocking & Doubles | mocking.md |
| Async & Error Handling | async-and-errors.md |
| Coverage & Configuration | coverage-and-config.md |
| TDD Cycle | tdd-patterns.md |
Example: TDD Calculator
See tdd-calculator.ts for the Red-Green-Refactor workflow.
Signals
- GitHub stars
- 20
- Forks
- 5
- Last commit
- Jul 2026
Advanced
- Catalog kind
- skill
- Gateway key
vitest-standard- Source
- github.com/neverinfamous/memory-journal-mcp