Cypress interview questions and answers

Cypress interview questions focus on how Cypress differs from WebDriver tools: it runs inside the browser next to your app, queues commands instead of running them at once, and retries queries and assertions until they pass or time out. Expect questions on that command queue, network stubbing with `cy.intercept`, fixtures, component testing and the tool's limits with multiple tabs, other origins and iframes, plus a comparison with Selenium and Playwright.

By Published 7 min read

Where Cypress questions come from

Cypress shows up in QA automation and SDET interviews at companies with JavaScript or TypeScript frontends, and in frontend developer loops where engineers own their end-to-end tests. The usual shape is a concepts round (architecture, commands, waiting), a hands-on round where you write or fix a spec against a sample app, and for senior roles a discussion of how a suite is organized, kept stable and run in CI. Interviewers often hire people moving from Selenium, so many questions probe whether you have actually unlearned WebDriver habits like explicit waits and storing elements in variables.

Architecture and core concepts

Cypress questions for freshers and early screens
QuestionWhat it testsWhat a strong answer shows
How is Cypress architecturally different from Selenium?ArchitectureSelenium sends commands from outside the browser over the WebDriver protocol. Cypress runs your test in the same browser as the app, so it can read the DOM, stub functions and see network traffic directly, with a Node process alongside for anything outside the browser.
What does cy.get return?Command modelNot the element. It enqueues a command and returns a chainable object; the element is yielded to the next command when the queue runs.
Why can you not use async/await with Cypress commands?Command modelCommands are not promises. They are queued and run later in order, and Cypress manages the timing. Use .then to work with a yielded value.
cypress open versus cypress run?Toolingopen starts the interactive runner with time travel snapshots for writing and debugging. run runs headlessly from the command line, which is what CI uses.
What is time travel in the runner?DebuggingThe runner keeps a DOM snapshot for each command, so you can hover over a step in the command log and see the page as it was at that moment.
Where does configuration live?SetupIn cypress.config.js or .ts, with separate e2e and component sections for things like baseUrl, spec patterns, viewport and timeouts.
Which browsers can Cypress run?CoverageChrome and other Chromium browsers, Firefox and the bundled Electron browser. WebKit support has been experimental, so Safari coverage is weaker than in Playwright.
What is cy.request for?SetupMaking HTTP requests from the test without the UI, usually to seed data or log in quickly. It is not intercepted and does not involve the page.
What is a custom command?ReuseA function added with Cypress.Commands.add, such as cy.login(), so common steps read as one line. Too many layers of custom commands make failures harder to trace.
Cypress questions for freshers and early screens. Scroll sideways on a small screen.

The command queue and retry-ability

  • Why does `const total = cy.get("[data-cy=total]").text()` not work? cy.get yields later, and the chainer has no text() method. Read the value inside .then or .invoke("text") and assert in the same chain.
  • Which commands retry? Queries such as get, find, contains and its retry until the assertions after them pass or the timeout hits. Actions such as click and type do not retry, but they first wait until the element is visible, enabled and not covered.
  • What is the default timeout for a query? The defaultCommandTimeout setting, four seconds unless changed. You can raise it for one command with { timeout: 10000 } rather than for the whole suite.
  • Why does `.should` retry but `.then` does not? .should re-runs its assertion and the query before it until it passes. .then runs its callback once with the yielded subject, so an assertion inside it fails immediately if the page is not ready.
  • What is wrong with `cy.wait(3000)`? It waits the full three seconds every run and still fails if the app is slower. Wait on an aliased request with cy.wait("@getOrders") or on an assertion about the page.
  • What are aliases? Names given with .as("name") to elements, intercepts or fixtures, then referenced with @name. Intercept aliases are the most useful, because waiting on them ties the test to the real event.
  • Why do you see "element is detached from the DOM"? The app re-rendered between finding the element and acting on it. Newer Cypress versions re-query more of the chain automatically, and the fix is still to wait for the re-render to finish before acting.
  • How do you share data between commands without globals? Aliases with this inside function() callbacks, or nesting the steps inside .then. Plain variables assigned in one command and read outside the chain will be empty.
cy.get("[data-cy=cart-total]")
  .invoke("text")
  .then((text) => {
    const total = Number(text.replace(/[^0-9.]/g, ""));
    expect(total).to.be.greaterThan(0);
  });

// Retries until the badge shows 3 or four seconds pass:
cy.get("[data-cy=cart-badge]").should("have.text", "3");
Reading a value the Cypress way. The callback runs when the queue reaches it, not when the line is first read.

Network control: cy.intercept and fixtures

  • What can `cy.intercept` do? Spy on matching requests, stub them with a static body or a fixture, change a real response before the app sees it, delay responses or force network errors.
  • When should you stub the backend and when should you hit the real one? Stub to test UI states quickly and reliably, especially errors and empty lists. Keep a smaller set of tests against a real backend so a broken contract is still caught.
  • What is a fixture? A file in cypress/fixtures, usually JSON, loaded with cy.fixture() or used directly as { fixture: "orders.json" } in an intercept.
  • How do you assert what the app sent? Wait on the alias and inspect it: cy.wait("@save").its("request.body").should("deep.equal", {...}).
  • If two intercepts match the same request, which wins? The one defined most recently, which lets a single test override a default stub from beforeEach.
  • How do you log in fast in every test? Log in through cy.request or a programmatic call and cache it with cy.session, so the UI login form is tested once, not before every spec.
describe("orders page", () => {
  beforeEach(() => {
    cy.intercept("GET", "/api/orders*", { fixture: "orders.json" }).as("getOrders");
    cy.visit("/orders");
    cy.wait("@getOrders");
  });

  it("lists the stubbed orders", () => {
    cy.get("[data-cy=order-row]").should("have.length", 3);
    cy.contains("[data-cy=order-row]", "ORD-1002").should("contain", "Shipped");
  });

  it("shows an error banner when the API fails", () => {
    cy.intercept("GET", "/api/orders*", { statusCode: 500, body: { code: "internal" } }).as("ordersDown");
    cy.reload();
    cy.wait("@ordersDown");
    cy.get("[role=alert]").should("be.visible").and("contain", "try again");
  });

  it("sends the cancel reason", () => {
    cy.intercept("POST", "/api/orders/*/cancel", { statusCode: 200, body: { status: "canceled" } }).as("cancel");
    cy.contains("[data-cy=order-row]", "ORD-1002").find("[data-cy=cancel]").click();
    cy.wait("@cancel").its("request.body").should("deep.equal", { reason: "customer_request" });
  });
});
cypress/e2e/orders.cy.js: stubbed list, an error state, and an assertion on the request body.

Component testing

  • What is Cypress component testing? Mounting a single React, Vue, Angular or Svelte component in a real browser with cy.mount and testing it with the same commands as end-to-end specs, without starting the whole app.
  • Component tests in Cypress or unit tests with Jest and React Testing Library? Cypress gives a real browser, real CSS and visual debugging; Jest with jsdom is faster and lighter for logic-heavy components. The Jest interview questions cover that side.
  • What do you still need end-to-end tests for? Routing, authentication, real API integration and flows that cross several pages.

Limits and how teams work around them

Intermediate questions about what Cypress cannot do easily
QuestionWhat it testsWhat a strong answer shows
How do you test a link that opens a new tab?Multi-tabCypress controls one tab. Assert the link's href and target, or remove target with invoke("removeAttr", "target") and follow it in the same tab.
How do you test a login on a different domain?Cross-originWrap the steps on the other domain in cy.origin(url, () => {...}), available in newer versions. Pass data into it through the args option, since the callback cannot see outer variables.
How do you work inside an iframe?IframesThere is no first-class command. Get the iframe's contentDocument body, wrap it with cy.wrap and query inside; a plugin can tidy this up. Cross-origin iframes are harder still.
How do you test hover menus?EventsCypress fires synthetic events, so CSS :hover is not triggered. Trigger mouseover or mouseenter when the menu uses JavaScript, or test the hover state at component level.
Can Cypress test a mobile app?ScopeNo. It tests web apps, and you can set a mobile viewport. Native apps need tools such as Appium.
What runs in Node instead of the browser?TasksAnything that needs the file system, a database or a server-side library. Expose it with cy.task in the config's setupNodeEvents.
Intermediate questions about what Cypress cannot do easily. Scroll sideways on a small screen.

Cypress versus Selenium and Playwright, and senior scenarios

Questions for experienced automation engineers
QuestionWhat it testsWhat a strong answer shows
Cypress or Selenium?Tool choiceCypress gives fast feedback, automatic waiting and strong debugging for JavaScript web apps. Selenium covers more languages and browsers, real multi-tab work and existing Grid setups.
Cypress or Playwright?Tool choicePlaywright drives browsers from outside, supports several languages, multiple tabs and contexts, and WebKit. Cypress has a gentler learning curve and the interactive runner. Team language and app needs decide.
How do you make a Cypress suite run faster in CI?ScaleSplit specs across machines (Cypress Cloud does this, or a spec-splitting plugin with your CI), seed data through APIs, cache login with cy.session, and stub slow third-party calls.
What does test isolation mean in Cypress?IsolationRecent versions clear the page, cookies and storage before each test by default, so tests cannot depend on each other. Older suites written to share state between it blocks break when it is turned on.
How do you handle secrets and per-environment URLs?ConfigEnvironment variables passed at run time or through CI secrets, read with Cypress.env() or config, never committed fixtures with real credentials.
A spec fails only in CI. Where do you look?DebuggingScreenshots and videos from the run, the viewport, a slower CI machine exposing a missing wait on a request, and data left by other specs running against the same environment.
Where do you put data-cy attributes, and who owns them?CollaborationDevelopers add them to elements the tests need, agreed in code review. They decouple tests from styling classes and copy changes.
Questions for experienced automation engineers. Scroll sideways on a small screen.

Fictional example

Answering "This test clicks Save and checks the toast. It fails in CI sometimes. Why?"
Interviewer
The spec does cy.get("[data-cy=save]").click(); cy.wait(1000); cy.get(".toast").should("contain", "Saved");. It passes locally and fails now and then in CI.
Candidate
The fixed wait is the smell. On a slow CI runner the save request can take longer than a second, and then the toast query only has its own four-second budget, which may also run out. I would replace the sleep with an intercept on the save call, aliased, and wait on that: cy.intercept("PUT", "/api/profile").as("save"), click, cy.wait("@save").its("response.statusCode").should("eq", 200), then assert on the toast. That ties the test to the actual event and also checks the request succeeded. I would also check the toast selector: a class like .toast might match an older toast that is still fading out, so a data-cy attribute with the message type is safer. Finally I would run the spec in a loop in CI with the same viewport to confirm it is stable before closing the ticket.

Cypress practice plan

  1. Set up a projectInstall Cypress in a small app, configure baseUrl, and write one spec in the interactive runner using time travel to watch each step.
  2. Unlearn sleepsWrite three tests that wait only on intercept aliases and assertions. Then add a cy.wait(2000) and explain why it is worse.
  3. Stub every stateUse cy.intercept and fixtures to show a loaded list, an empty list, a server error and a slow response with a spinner.
  4. Hit the limitsTest a new-tab link, a login on another origin with cy.origin, and a form inside an iframe, and note the workaround for each.
  5. Rehearse comparisonsPrepare a two-minute answer on Cypress versus Selenium versus Playwright for a team like the one you are interviewing with.

For the strategy side of the same job, read the automation testing interview questions. For frontend loops, frontend developer interview questions cover the rest of the round.

Debugging a spec out loud is a skill of its own. Natively, an AI interview assistant for Mac and Windows, keeps a transcript of your mock Cypress session so you can see whether you explained retry-ability clearly or rushed into code. While you practice it can read a screenshot of the runner's command log or an error and suggest what to look at, help with the spec you are writing, and, with Pro or the free trial, ground its suggestions in the résumé and job description you add. You can review the transcript and notes after each run.

Questions people ask

What Cypress questions are asked in interviews?

How Cypress differs from Selenium, why commands are queued and not awaited, which commands retry, cy.intercept and fixtures, aliases, component testing, test isolation and the multi-tab and cross-origin limits.

Why can you not use async/await with Cypress commands?

Cypress commands are queued and run later in order, not returned as promises. Read yielded values with .then or invoke and assert in the same chain.

How does Cypress handle another domain or a new tab?

Steps on another origin go inside cy.origin. Cypress controls a single tab, so tests usually check the link's href or remove target and follow it in the same tab.

What Cypress questions do experienced testers get?

Flaky specs in CI, replacing fixed waits with intercept aliases, cy.session for login, running specs in parallel, stubbing versus real backends, and choosing between Cypress, Selenium and Playwright.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP