vitest-unit-component-engineer

Write Vitest unit and component tests with environment selection and deterministic mocks.

2|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/nguyenpv1980-wq/Project-Aegis --skill vitest-unit-component-engineer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vitest-unit-component-engineer
Source: https://github.com/nguyenpv1980-wq/Project-Aegis/tree/main/.claude/skills/vitest-unit-component-engineer
Command: npx skills add https://github.com/nguyenpv1980-wq/Project-Aegis --skill vitest-unit-component-engineer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill removes guesswork from Vitest testing by helping you write fast, deterministic unit and component tests that match the actual behavior of your code.

Core Features & Use Cases

  • Environment Selection: Chooses node for pure logic and jsdom or happy-dom only when DOM behavior is real and needed.
  • Behavior-Focused Testing: Uses observable outcomes, Testing Library queries, and userEvent instead of implementation-coupled assertions.
  • Deterministic Test Design: Handles fake timers, owned-boundary mocks, and setup changes while avoiding flaky network, time, and randomness dependence.
  • Real Execution Reporting: Runs the suite manually and reports the exact command plus genuine pass/fail output.
  • Use Case: A developer needs tests for a currency formatter, a reducer, and a React invoice row component, with clear environment choices and honest results.

Quick Start

Ask the skill to write or fix Vitest tests for a utility or component suite, and include the files, behavior to cover, and any environment or setup constraints.

Frequently Asked Questions about vitest-unit-component-engineer

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

FAQPage Schema
How do I write deterministic Vitest unit tests for pure logic and UI components?

Deterministic Vitest unit tests require isolating pure logic and UI components using owned-boundary mocks, fake timers, and Testing Library userEvent queries to assert observable behavior without relying on real services or network boundaries.

When should I use jsdom or happy-dom versus the node environment in Vitest?

Use the node environment in Vitest for pure logic like utilities and reducers, and select jsdom or happy-dom only when real DOM behavior is explicitly needed for component testing and observable user-facing assertions.

What's the best way to mock dependencies in Vitest component testing?

The best way to mock dependencies in Vitest component testing is applying deterministic mocks strictly at owned seams, preventing flaky network, time, or randomness dependence while maintaining behavior-focused assertions through Testing Library queries.

How do I test React component behavior with Vitest without coupling to implementation details?

Test React component behavior with Vitest by using Testing Library queries and userEvent to verify observable outcomes, avoiding implementation-coupled assertions, and selecting jsdom or happy-dom only when actual DOM interaction is required.

Can I use Vitest for testing reducers, validators, and mappers without a real database?

Yes, Vitest is designed for testing reducers, validators, and mappers by using deterministic mocks at owned boundaries to isolate pure logic, ensuring fast tests without real database, auth, or browser-journey dependencies.

Why are my Vitest tests flaky and how do I fix time or randomness dependence?

Flaky Vitest tests often stem from uncontrolled time or randomness dependence; fix them by implementing deterministic test design with fake timers and owned-boundary mocks to ensure consistent, predictable test execution.