testing-infrastructure

Configure Vitest, React Testing Library, and MSW mocks for monorepo CI testing.

2|1|Updated Jan 7, 2021
One-click install
npx skills add https://github.com/lsst-sqre/squareone --skill testing-infrastructure-lsst-sqre
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-infrastructure
Source: https://github.com/lsst-sqre/squareone/tree/main/.claude/skills/testing-infrastructure
Command: npx skills add https://github.com/lsst-sqre/squareone --skill testing-infrastructure-lsst-sqre

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pnpm, vitest, storybook, @testing-library/react, user-event, msw.

What problem does it solve?

Developers struggle with inconsistent testing setups, complex configurations, and debugging test failures across a monorepo. This skill centralizes all testing knowledge, making it easy to write, configure, and troubleshoot tests.

Core Features & Use Cases

  • Comprehensive Testing Guidance: Covers Vitest, React Testing Library, Storybook tests, and CI pipeline integration.
  • Mocking & Data Setup: Provides patterns for mocking functions, modules, SWR, and setting up mock data with MSW.
  • CI Pipeline Integration: Explains the test-suite-runner agent for automated, comprehensive testing and detailed failure reports.
  • Use Case: When a CI pipeline fails due to a test, use this skill to quickly understand the Vitest configuration, debug the specific test, and apply best practices for mocking and user interactions to fix it.

Quick Start

Explain how to run unit tests for the @lsst-sqre/squared package. pnpm test --filter @lsst-sqre/squared

Frequently Asked Questions about testing-infrastructure

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

FAQPage Schema
How do I set up testing infrastructure for a monorepo with Vitest and React Testing Library?

Vitest provides scalable testing infrastructure for monorepos by centralizing configuration across unit tests and Storybook tests. Use pnpm workspaces to run tests per package with `pnpm test --filter @package-name`, then apply React Testing Library patterns for user-focused assertions and MSW for API mocking to ensure consistent test behavior across your monorepo.

What's the best way to mock API calls in tests with MSW?

MSW-based API mocking intercepts HTTP requests at the network layer, letting you define mock handlers once and reuse them across unit and integration tests. This approach avoids brittle module-level mocks and ensures your tests validate real request/response patterns without hitting live endpoints.

How do I run Vitest tests in a CI pipeline and debug failures?

Use the test-suite-runner agent to execute comprehensive tests across your monorepo in CI, generating detailed failure reports that pinpoint which Vitest configuration, React Testing Library assertion, or mock setup caused the failure. This enables rapid debugging without manual log parsing.

Can I test Storybook stories with Vitest?

Yes, Storybook's addon-vitest integration lets you run Vitest tests directly against your stories, enabling you to validate component rendering, interactions, and visual behavior alongside unit tests in the same configuration and test runner.

Do I need to configure Vitest separately for unit tests and Storybook tests?

No, centralized Vitest configuration satisfies both unit test execution and Storybook addon-vitest requirements. A single setup handles mocking, module resolution, and test discovery, eliminating configuration duplication across testing contexts.

What testing patterns work best for React components in a monorepo?

Combine React Testing Library's user-interaction focus with mock data utilities and MSW API mocks to test components realistically. This skill provides pre-built patterns for testing hooks, context providers, and async interactions that scale across multiple packages without coupling tests to implementation details.