write-vitest

Classify unit, hook, and component tests for Vitest with Testing Library and axe.

1|Updated Apr 21, 2026
One-click install
npx skills add https://github.com/sswapnil2/ai-config-fintech --skill write-vitest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-vitest
Source: https://github.com/sswapnil2/ai-config-fintech/tree/main/skills/write-vitest
Command: npx skills add https://github.com/sswapnil2/ai-config-fintech --skill write-vitest

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing tests that verify core logic, hooks, and UI components using Vitest often lacks standardized patterns. This Skill provides a clear approach to structure unit, hook, and component tests for React/Next and SvelteKit apps, ensuring consistent test quality and maintainability.

Core Features & Use Cases

  • Unit tests: test pure functions with parameterized cases to cover edge conditions.
  • Hook tests: isolate React hooks with proper test utilities and providers.
  • Component tests: verify React and Svelte components using Testing Library patterns and a11y checks.
  • Guardrails: enforce no snapshot tests for dynamic UI, use MSW for API interactions, and include accessibility checks.

Quick Start

Create a test file beside the module (foo.test.tsx / Foo.test.ts) and run pnpm test <file> to execute the tests.

Frequently Asked Questions about write-vitest

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

FAQPage Schema
How do I structure Vitest tests for React and SvelteKit components?

Identify what to test in a module and classify test types into unit, hooks, and components to create focused Vitest tests. Cover React/Next and SvelteKit components using Testing Library patterns to ensure consistent test quality and maintainability.

Why should I avoid snapshot tests for dynamic UI components in Vitest?

Avoid snapshot tests for dynamic UI because they create brittle test failures and mask actual component behavior. Enforce testing guardrails that use MSW for API interactions and include accessibility checks with axe for more robust validations.

How do I test React hooks with Vitest and Testing Library?

Isolate React hooks in Vitest by classifying them as hook tests and using proper test utilities and providers. This separates hook logic from pure unit functions and component rendering to ensure focused test coverage.

Can I use Vitest to run accessibility checks on SvelteKit components?

Yes, Vitest can run accessibility checks on SvelteKit components by requiring axe for a11y validations. Component tests verify Svelte UI using Testing Library patterns while enforcing accessibility standards.

What is the best way to cover edge conditions in Vitest unit tests?

Test pure functions with parameterized cases to cover edge conditions in Vitest unit tests. This approach ensures your core logic handles various inputs correctly and maintains consistent behavior across different scenarios.