AGENTS.md

GitHub

Vitest

Version 1.0.0
community
January 2026

Note:
This document is mainly for agents and LLMs to follow when maintaining,
generating, or refactoring codebases. Humans may also find it useful,
but guidance here is optimized for automation and consistency by AI-assisted workflows.


Abstract

Comprehensive testing best practices guide for Vitest, designed for AI agents and LLMs. Contains 44 rules across 8 categories, prioritized by impact from critical (async patterns, test isolation) to incremental (test organization). Each rule includes detailed explanations, real-world examples comparing incorrect vs. correct implementations, and specific impact metrics to guide automated test writing and code review.


Table of Contents

  1. Async Patterns — CRITICAL
  2. Test Setup & Isolation — CRITICAL
  3. Mocking Patterns — HIGH
  4. Performance — HIGH
  5. Snapshot Testing — MEDIUM
  6. Environment — MEDIUM
  7. Assertions — LOW-MEDIUM
  8. Test Organization — LOW

References

  1. https://vitest.dev/guide/improving-performance
  2. https://vitest.dev/guide/profiling-test-performance
  3. https://vitest.dev/guide/mocking
  4. https://vitest.dev/guide/snapshot
  5. https://vitest.dev/guide/browser/component-testing
  6. https://trunk.io/blog/how-to-avoid-and-detect-flaky-tests-in-vitest
  7. https://mswjs.io/docs/

Source Files

This document was compiled from individual reference files. For detailed editing or extension:

File Description
references/_sections.md Category definitions and impact ordering
assets/templates/_template.md Template for creating new rules
SKILL.md Quick reference entry point
metadata.json Version and reference URLs