react-vitest

A testing guide for React applications that use Vitest, a JavaScript test runner. It covers component tests with React Testing Library, which checks components as users interact with them, plus mocks and coverage settings.

In plain words
What is it for?
Setting up Vitest, testing clicks and other user actions, replacing hooks or dependencies with test doubles, and enforcing test-coverage thresholds.
Why use it?
It provides a consistent way to check that React components behave correctly and that tests can run in development and continuous integration.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/drvoss/everything-copilot-cli/react-vitest
Any agent
npx skills add drvoss/everything-copilot-cli --skill react-vitest
Clone the repo
git clone --depth 1 https://github.com/drvoss/everything-copilot-cli

Made for: Claude Code, Codex.

Per session 33 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 722 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00033 $0.00722
Opus 5 $0.00016 $0.00361
Sonnet 5 $0.00007 $0.00144
Haiku 4.5 $0.00003 $0.00072

Measured 2d ago against content hash d1b11bed40a5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

react-vitest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/development/react-vitest/SKILL.md · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

React + Vitest Combo Skill

When to Use

  • Setting up Vitest in a React (Vite-based) project for the first time
  • Writing component tests using React Testing Library
  • Mocking context providers, hooks, or module dependencies in tests
  • Configuring coverage thresholds for CI enforcement

Workflow

1. Setup

pnpm add -D vitest @vitest/ui jsdom @testing-library/react @testing-library/user-event @testing-library/jest-dom
// vitest.config.ts
import { defineConfig } from "vitest/config"
import react from "@vitejs/plugin-react"

export default defineConfig({
  plugins: [react()],
  test: {
    environment: "jsdom",
    globals: true,
    setupFiles: ["./src/test/setup.ts"],
    coverage: {
      provider: "v8",
      thresholds: { lines: 80, branches: 70 },
    },
  },
})
// src/test/setup.ts
import "@testing-library/jest-dom"

2. Component Test Pattern

// src/components/Button.test.tsx
import { render, screen } from "@testing-library/react"
import userEvent from "@testing-library/user-event"
import { Button } from "./Button"

describe("Button", () => {
  it("calls onClick when clicked", async () => {
    const handleClick = vi.fn()
    render(<Button onClick={handleClick}>Submit</Button>)

    await userEvent.click(screen.getByRole("button", { name: "Submit" }))

    expect(handleClick).toHaveBeenCalledOnce()
  })
})

3. Wrapping with Providers

// src/test/utils.tsx
import { render, RenderOptions } from "@testing-library/react"
import { ReactElement } from "react"
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"

const AllProviders = ({ children }: { children: React.ReactNode }) => {
  const queryClient = new QueryClient({
    defaultOptions: { queries: { retry: false } },
  })
  return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
}

export const renderWithProviders = (ui: ReactElement, options?: RenderOptions) =>
  render(ui, { wrapper: AllProviders, ...options })

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 117 lines · 33 tokens per session scan A d1b11bed40a5

Subscribe to this mod's changes

react-vitest is a skill published in the GitHub repository drvoss/everything-copilot-cli (45 stars, last pushed 6d ago), licensed MIT. It adds 33 tokens to every session and 722 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

vitest

Vitest unit testing patterns with React Testing Library. Trigger: When writing unit tests for React components, hooks, or utilities.

prowler-cloud/prowler · 28 tokens

frontend-testing

Generate Vitest + React Testing Library tests for Dify frontend components, hooks, and utilities. Triggers on testing, spec files, coverage, Vitest, RTL, unit tests, integration tests, or write/review test requests.

Ohh-889/skyroc · 50 tokens

frontend-testing

Use when writing or changing Vitest or React Testing Library tests under web/ or packages/dify-ui/, or when the user explicitly requests frontend test strategy, including evaluation of an existing strategy. Do not use for frontend code-review-only requests, general testability discussion, Python tests, or…

langgenius/dify · 73 tokens

react-testing

Write and review React/TypeScript tests for Sentry's frontend using Jest and React Testing Library. Use when adding or editing tests in static/ (.spec.tsx), writing component/hook tests, mocking API responses with MockApiClient, testing routing or network requests, or when asked to "write a frontend test", "add a…

getsentry/sentry · 86 tokens

playground-msw-tests

REQUIRED and PRIMARY testing approach for packages/playground and packages/playground-ui. Triggers on: adding or modifying hooks, pages, route components, data-fetching code, React Query interactions, or any test work in these packages. Generates Vitest tests that drive the real @mastra/client-js + React Query stack…

mastra-ai/mastra · 121 tokens

unit-tests

Jest + React Testing Library best practices for Wonder Blocks unit tests. Use when creating or editing .test.ts / .test.tsx files.

Khan/wonder-blocks · 34 tokens