vitest-guidelines

Establish testing guidelines for Vitest and Jest test suites.

1|Updated Dec 1, 2025
One-click install
npx skills add https://github.com/hypeJunction/ai-assistant-starter --skill vitest-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest-guidelines
Source: https://github.com/hypeJunction/ai-assistant-starter/tree/main/skills/vitest-guidelines
Command: npx skills add https://github.com/hypeJunction/ai-assistant-starter --skill vitest-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, actionable guidelines and best practices for writing effective tests using Vitest and Jest, ensuring consistency and maintainability in your testing suite.

Core Features & Use Cases

  • Test Structure: Enforces patterns like AAA (Arrange-Act-Assert) and Given-When-Then.
  • Query Priority: Guides the selection of appropriate Testing Library queries for robust element selection.
  • Mocking Strategies: Demonstrates effective function, module, and spy mocking techniques.
  • Use Case: When writing a new test for a component, consult this Skill to ensure you're following the recommended structure, using the correct queries, and mocking dependencies appropriately.

Quick Start

Follow the provided guidelines for structuring your Vitest tests and selecting Testing Library queries.

Frequently Asked Questions about vitest-guidelines

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

FAQPage Schema
What is the best way to structure Vitest and Jest tests for maintainability?

Effective Vitest and Jest test structure relies on AAA (Arrange-Act-Assert) or Given-When-Then patterns. These guidelines establish consistent test suites by standardizing organization, ensuring clarity and long-term maintainability in JavaScript and TypeScript projects.

How do I select the right Testing Library queries for component testing?

Selecting Testing Library queries requires prioritizing accessibility-aware element selection for robust component testing. These guidelines direct you toward query choices reflecting user interactions with the DOM, yielding resilient tests that avoid breaking on implementation changes.

Can I use the same mocking strategies for modules and functions in Vitest?

Yes, you can apply consistent mocking strategies for modules and functions in Vitest. These guidelines demonstrate effective techniques for mocking functions, modules, and using spies, ensuring proper test isolation across JavaScript and TypeScript test suites.

Does this testing approach work for both JavaScript and TypeScript projects?

Yes, this testing approach works for both JavaScript and TypeScript projects. The guidelines establish comprehensive testing patterns for Vitest and Jest that address the need for consistent and maintainable test suites across both language environments.

Why should I prioritize test isolation when writing Jest or Vitest test suites?

You should prioritize test isolation to prevent state leakage and ensure consistent execution in Jest or Vitest test suites. These guidelines enforce best practices for effective test isolation, critical for maintaining reliable testing workflows in growing projects.