frontend-unit-testing

Test React frontend code with Vitest using project utilities and MSW mocking.

Updated Feb 26, 2026
One-click install
npx skills add https://github.com/Trimud/Sheep-Vampires-Yoghurt --skill frontend-unit-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-unit-testing
Source: https://github.com/Trimud/Sheep-Vampires-Yoghurt/tree/main/.claude/skills/frontend-unit-testing
Command: npx skills add https://github.com/Trimud/Sheep-Vampires-Yoghurt --skill frontend-unit-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The Frontend Unit Testing Skill provides project-specific conventions to write, debug, and review Vitest unit tests for the React storefront, ensuring tests align with repository standards and testing patterns.

Core Features & Use Cases

  • Enforces non-import of vitest globals and promotes usage of project test utilities like ConfigWrapper/createConfigWrapper, createTestContext, and createFormDataRequest.
  • Encourages MSW-based API mocking, renderHook/render tests with the provided wrappers, and userEvent.setup() for interactions.
  • Covers a broad range of testing scenarios including component rendering, hooks, providers, and route/server-action tests while maintaining coding standards.

Quick Start

Begin by adding Vitest-based unit tests for frontend components and hooks that follow the project conventions and use the provided wrappers and utilities.

Frequently Asked Questions about frontend-unit-testing

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

FAQPage Schema
How do I write Vitest tests for React components using project conventions?

To write Vitest tests for React components, use project utilities like ConfigWrapper or createConfigWrapper for rendering, and userEvent.setup() for interactions, ensuring tests align with repository standards.

What is the best way to mock API requests in frontend unit testing?

The best way to mock API requests in frontend unit testing is using MSW (Mock Service Worker), which intercepts network requests to provide controlled response data for your component and route tests.

How do I test React hooks with Vitest in a monorepo?

To test React hooks with Vitest, use the renderHook utility combined with project-specific wrappers like createTestContext and ConfigWrapper to provide necessary providers and context to your hooks.

Can I import vitest globals directly in my React testing setup?

No, you should avoid direct imports from vitest globals. Instead, follow project conventions by using the provided test utilities and wrappers to maintain consistent testing patterns across the repository.

How do I test route and server actions under the frontend directory?

To test route and server actions under the frontend directory, utilize createTestContext and createFormDataRequest utilities alongside MSW for mocking, ensuring proper coverage of interactions and providers.

Does this testing approach work for testing React providers and context?

Yes, this approach works for testing React providers and context by leveraging createTestContext and ConfigWrapper, which allow you to wrap components with necessary providers during rendering and hook tests.