react-vitest
/react-vitest
Dodaje i poprawia testy w projekcie React z Vitest: testy komponentów z Testing Library, mockowanie hooków i konfiguracja pokrycia.
- Autor
- drvoss ↗
- Repozytorium
- everything-copilot-cli ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 25.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 25.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Dodaje i poprawia testy w projekcie React z Vitest: testy komponentów z Testing Library, mockowanie hooków i konfiguracja pokrycia.
Oryginalny opis (EN)
Use when adding or improving tests in a React project that uses Vitest — covers component testing with Testing Library, mocking hooks, and coverage configuration.
Jak działa
- When to Use
- Workflow
- Rules Applied
Podgląd SKILL.md
---
name: react-vitest
description: Use when adding or improving tests in a React project that uses Vitest — covers component testing with Testing Library, mocking hooks, and coverage configuration.
metadata:
category: development
agent_type: general-purpose
combo: "react, vitest"
---
# 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
```bash
pnpm add -D vitest @vitest/ui jsdom @testing-library/react @testing-library/user-event @testing-library/jest-dom
```
```typescript
// 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 },
},
},
})
```
```typescript
// src/test/setup.ts
import "@testing-library/jest-dom"
```
### 2. Component Test Pattern
```typescript
// 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
```typescript
// 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 })
```
### 4. Mocking Modules
```typescript
// Mock a module at the top of the test file
vi.mock("@/lib/api", () => ({
fetchUser: vi.fn().mockResolvedValue({ id: 1, name: "Alice" }),
}))
```
### 5. Running Tests
```bash
# Watch mode (development)
pnpm vitest
# Single run + coverage (CI)
pnpm vitest run --coverage
# UI mode
pnpm vitest --ui
```
## Rules Applied
- `rules/frameworks/react.md` — component design, hooks, accessibility
- `rules/frameworks/vitest.md` — test structure, assertions, mocking, coverage
- `rules/common/testing.md` — general test principles
Wersje
W bazie nie ma innych skilli o nazwie react-vitest.
Migawka bazy z 28.10.2026 · wersja paczki 1ebdff0e2bc1 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100vitest-testing-patterns
Pisze testy w Vitest i React Testing Library: testy jednostkowe, komponentów i integracyjne, mockowanie zależności, pokrycie i dobre praktyki. - 100vitest-testing-patterns
Pisze testy w Vitest i React Testing Library: testy jednostkowe, komponentów i integracyjne, mockowanie zależności, pokrycie i dobre praktyki. - 100testing-react
Pisze testy komponentów, hooków i utilities w React i TypeScript przy użyciu Vitest oraz React Testing Library. - 100react-testing
Testuje komponenty React z React Testing Library oraz Jest lub Vitest. - 100react-testing
Opisuje testowanie komponentów React z Testing Library i Vitest: testy jednostkowe i integracyjne, asynchroniczne, mockowanie, zdarzenia użytkownika i dostępność. - 100react-testing
Opisuje wzorce testowania komponentów React: komponenty, hooki, kontekst i formularze, z Vitest Browser Mode, vitest-browser-react i @testing-library/react.