Cypress · Browser testing end to end

How does Cypress component testing work?

Mediumcomponent testingmountreactUpdated Oct 2026
Quiz this track

Short answer

Component testing mounts a component directly in a real browser with the mount helper, without the full application. It gives browser-accurate rendering with faster, more focused tests.

Component tests sit between unit tests and end-to-end tests. Instead of visiting a route, you mount one component with its props and interact with it. Cypress runs the component in a real browser, so layout, focus and events behave as they do in the app without starting the whole application.

tsx
import { mount } from "cypress/react";
import { Counter } from "../../src/Counter";

describe("Counter", () => {
  it("increments when clicked", () => {
    mount(<Counter start={0} step={2} />);

    cy.contains("button", "Add").click();
    cy.contains("[data-cy=value]", "2").should("be.visible");
  });
});
The component is mounted with explicit props, so the test does not depend on the app's routing or data layer.

What to cover

  • Rendering of props and conditional branches
  • User interactions such as typing, selecting and keyboard behaviour
  • Validation and error presentation inside the component
  • Integration with a small state or context provider
  • Visual states that are hard to reach through the full app

Component tests need the same mocking discipline as unit tests. Stub network calls at the boundary, provide the required context, and avoid importing the entire app shell. If a test needs routing, authentication and a database, it is probably an end-to-end test in disguise.

Use the mount helper for your framework, such as cypress/react, cypress/vue or cypress/angular. The component dev server is configured separately from the e2e config.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How is component testing different from end-to-end testing?
  2. 2What does the mount helper do?
  3. 3When should a test move from component to e2e?
  4. 4How do you provide context to a mounted component?

Say it in the interview

Component testing mounts one component in a real browser with the framework's mount helper. I pass explicit props and stub the boundaries the component needs, so the test focuses on rendering and interaction without the whole app. It is faster and more targeted than e2e, but when a test needs routing, auth and a database, I move it to end-to-end. Both modes use the same runner.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Cypress mock interview and get scored feedback on depth, clarity and confidence.