SoftwareTestPilot
Automation TestingPublished: 10 min read

Cypress Component Testing — The Complete Guide (2026)

Test React, Vue, and Angular components in a real browser at unit-test speed. Full setup, mounting patterns, mocking, network stubs, and a design-system regression suite.

Avinash K
Founder & QA Engineer at SoftwareTestPilot
Share:XLinkedInWhatsApp
Cypress component testing setup for React, Vue, and Angular.
Cypress component testing setup for React, Vue, and Angular.

Last updated 2026-07-20 · 10 min read · By Avinash K

Component testing is Cypress's killer feature and the reason many teams still choose it over Playwright. You mount a component in a real browser, at ~50ms per test, with the same debugging UX as E2E. This guide covers React + Vue + Angular setup, mocking patterns, and the design-system regression suite that keeps our design tokens honest.

Key takeaways

  • Component setup for React, Vue, and Angular.
  • Mount + prop patterns.
  • Network stubs at the component level.
  • A design-system regression pattern.

1. Setup

npx cypress open --component
# Cypress detects your framework and generates cypress.config.ts + support files

2. Mount patterns

import { mount } from 'cypress/react';
import { Button } from '@/components/Button';

it('renders and clicks', () => {
  const onClick = cy.stub().as('onClick');
  mount(<Button onClick={onClick}>Save</Button>);
  cy.get('button').click();
  cy.get('@onClick').should('have.been.calledOnce');
});

3. Network stubs

cy.intercept('GET', '/api/users', { fixture: 'users.json' });
mount(<UserList />);
cy.contains('Alice').should('be.visible');

Same cy.intercept API you use for E2E — no MSW required.

4. Design system regression pattern

Mount every design-system component in every documented state (default, hover, disabled, error, loading). Combine with visual regression snapshots and you catch 90% of design token regressions before merge. Related: framework decision matrix, POM guide. Docs: docs.cypress.io/guides/component-testing.

Frequently asked questions

1.Component test vs Jest / Vitest?
Cypress runs in a real browser (real DOM, real events, real styles). Jest/Vitest use jsdom which mis-renders CSS layout, focus, and pointer events.
2.How fast?
First mount ~1s, subsequent mounts ~50-200ms. Slower than Vitest, faster and more realistic than Playwright browser tests.
3.Angular support?
Yes since Cypress 10 — full standalone-component support since 12.
4.Can I share code with E2E tests?
Yes — same commands, same intercept, same assertions. Only the mount step differs.