vitest
Installation
SKILL.md
For E2E tests: Use
prowler-test-uiskill (Playwright). This skill covers unit/integration tests with Vitest + React Testing Library.
Prowler UI Test Projects (ui/vitest.config.ts)
| Project | Files | Environment | Setup |
|---|---|---|---|
unit |
**/*.test.{ts,tsx} (excludes tests/**, *.integration.test.*) |
jsdom, no React Compiler | vitest.setup.ts (jest-dom matchers, storage mock) |
integration |
**/*.integration.test.{ts,tsx} |
Vitest browser mode, Playwright Chromium, React Compiler | vitest.integration.setup.ts (MSW worker, globals.css, mocks for @/auth.config, next/cache, server-only) |
- Tests are co-located next to the code (
foo.ts->foo.test.ts); shared fixtures live inui/__tests__/. - Config sets
globals,restoreMocks,mockReset,unstubEnvs,unstubGlobals: do not addafterEach(vi.restoreAllMocks)boilerplate. - Integration tests import
page/userEventfromvitest/browser, render with@/__tests__/render-browser, and mock HTTP with MSW (ui/__tests__/msw/), notvi.mockof fetch.
Test Structure (REQUIRED)
Use Given/When/Then (AAA) pattern with comments: