Modern test suites mix component and E2E tests at different ratios. Component tests give fast feedback on UI units; E2E tests give high signal on user journeys. This guide explains when to invest in each, with code samples and a real ratio recommendation.
What is component testing?
A component test mounts a single UI component in isolation and asserts on its behaviour. No server, no router, no full app. Cypress Component Testing supports React, Vue, Angular, and Svelte.
Component vs E2E trade-offs
- Component — fast (sub-second), cheap to maintain, narrow scope.
- E2E — slow (seconds to minutes), catches integration issues, broad scope.
A practical ratio
- 70% component tests (covers UI logic in isolation).
- 20% integration tests (covers flows across 2-3 components + API mocks).
- 10% E2E tests (covers the critical user journeys end to end).
Code example: Cypress component test
Where component tests shine
- UI units with branching logic — buttons, modals, forms, dropdowns with multiple states.
- Edge-case rendering — empty states, error states, loading skeletons, long strings, RTL languages.
- Component-level accessibility — `cy.injectAxe()` runs axe-core against the mounted component in milliseconds.
- Visual regression — pair component tests with Cypress's screenshot plugin for pixel-level diffing.
Where E2E tests still win
- Routing and deep linking — verify guards, redirects, query params.
- Auth + session flows — sign-in, sign-up, password reset, MFA challenges.
- Cross-page integrations — checkout, onboarding, anything that touches several services.
- Real browser engine quirks — only a real E2E run hits engine-specific behaviour that component tests skip.
Network mocking strategies
Component tests stub the network via `cy.intercept()` so a single component is tested in isolation. E2E tests prefer real services for happy paths, but stub flaky or third-party APIs. The same `cy.intercept()` API works in both modes; only the policy differs.







