Frontend Testing Toolkit
Vitest, Testing Library, Playwright, and Storybook integration for unit, integration, and E2E testing.
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 28 files
📖 Documentation Preview README excerpt
Frontend Testing Toolkit
A complete testing setup for React applications covering unit, integration, and end-to-end testing with Vitest, Testing Library, Playwright, and Storybook. This toolkit includes example components with their corresponding tests at every level, plus CI configuration and a testing strategy guide.
What's Inside
Example Components (`src/components/`)
Three real components that demonstrate common UI patterns — a search input with debounce, a data table with sorting and pagination, and a modal dialog with focus management. These aren't toy examples; they handle edge cases like keyboard navigation, loading states, and accessibility attributes.
Component Tests (`tests/unit/`)
Unit and integration tests written with Vitest + Testing Library. Each component has tests covering:
- Rendering with various props
- User interactions (click, type, keyboard)
- Async behavior (debounce, data loading)
- Accessibility (ARIA attributes, focus management)
- Edge cases (empty states, error states, long text)
End-to-End Tests (`tests/e2e/`)
Playwright specs that test complete user workflows across multiple components. Includes Playwright configuration with multiple browser targets and screenshot comparison setup.
Storybook Stories (`stories/`)
Component stories for visual testing and documentation. Each story demonstrates different component states (default, loading, error, empty) and interaction patterns.
Test Utilities (`tests/utils/`)
Reusable helpers that reduce boilerplate across your test suite:
- Custom render function with providers (router, query client, theme)
- Mock factories for common data shapes
- Fixture data for consistent test scenarios
- Custom matchers and assertion helpers
Configuration (`configs/`)
Ready-to-use configuration files for Vitest, Storybook, and CI/CD pipelines.
Testing Strategy Guide (`guides/testing-strategy.md`)
A practical guide covering what to test at each level, how to decide between unit and integration tests, and how to avoid the common pitfalls that make test suites slow and fragile.
Quick Start
# Install dependencies
npm install -D vitest @testing-library/react @testing-library/jest-dom @testing-library/user-event
npm install -D @playwright/test
npm install -D @storybook/react-vite storybook
# Run unit tests
npx vitest
# Run E2E tests
npx playwright test
# Start Storybook
npx storybook dev -p 6006
File Structure
frontend-testing-toolkit/
├── README.md
├── LICENSE
*... continues with setup instructions, usage examples, and more.*