Cypress interview questions

// 48 QUESTIONS · UPDATED MAY 2026

Cypress 13+ interview questions covering custom commands, sessions, intercept, retry-ability, component testing, and architecture decisions.

Level

Showing 48 of 48 questions

  1. What makes Cypress different from Selenium?Junior

    Cypress runs in the same browser process as your app, giving direct DOM access, automatic waits, and time-travel debugging. Selenium driv…

  2. Explain Cypress retry-ability in your own words.Mid

    Most Cypress commands and assertions automatically re-run for a few seconds until they pass or time out, so you rarely need explicit wait…

  3. How do you handle authentication efficiently in a large Cypress suite?Senior

    Use cy.session() to cache login state per user role, hit the API directly for the login itself, and avoid logging in through the UI in ev…

  4. What is the architecture of Cypress and how does it differ from WebDriver-based tools?Junior

    Cypress runs *inside* the browser as JavaScript with full DOM and network access. WebDriver tools run as a separate process driving the b…

  5. What file structure does a typical Cypress project have?Junior

    `cypress.config.ts` at the root, plus a `cypress/` folder with subfolders `e2e/` (specs), `fixtures/` (test data), `support/` (custom com…

  6. How do you run a single Cypress test from the command line?Junior

    Use `npx cypress run --spec 'cypress/e2e/path/to/file.cy.ts'`. To run a specific test inside a spec, use `it.only(...)` in the code, or `…

  7. What does cy.visit() do and what URL does it default to?Junior

    `cy.visit(url)` navigates to the URL and waits for the page `load` event. Relative URLs are resolved against `baseUrl` from `cypress.conf…

  8. How do you write your first assertion in Cypress?Junior

    Chain `.should('assertion', value)` after a query like `cy.get(...)`. Cypress retries the chain until the assertion passes or the timeout…

  9. What is the role of cypress.config.ts (or .js)?Junior

    It's the single source of truth for Cypress configuration — baseUrl, viewport, timeouts, retries, environment variables, and per-mode (e2…

  10. What are Cypress hooks (before, beforeEach) and how are they different from before/after in Mocha?Junior

    Cypress uses Mocha's hooks: `before` (once per file), `beforeEach` (per test), `afterEach` (per test), `after` (once per file). They beha…

  11. How does Cypress handle async behaviour without async/await?Junior

    Cypress queues commands synchronously into an internal command queue, then executes them asynchronously in order. `cy.get(...).click()` d…

  12. What is the Test Runner UI and how is it different from cypress run?Junior

    `cypress open` launches the interactive Test Runner — a desktop app where you pick specs, watch them run in a real browser, and time-trav…

  13. How do you select elements in Cypress and what's the recommended selector strategy?Junior

    Use `cy.get(selector)` for CSS, `cy.contains(text)` for text, `cy.find()` to scope inside another element. Cypress recommends `data-test`…

  14. How does cy.intercept differ from cy.route (which is removed)?Mid

    `cy.intercept` is the modern network-handling API: it intercepts `fetch` *and* `XMLHttpRequest`, supports stubbing, spying, and dynamic p…

  15. When would you use cy.session over a custom login command?Mid

    `cy.session` caches the logged-in state across tests (and optionally specs), avoiding re-login for every test. A plain custom command log…

  16. How do you debug a flaky test in Cypress?Mid

    Reproduce locally with `cypress run` (not `open`), then use `--browser chrome --headed` plus `.only` to isolate. Inspect the recorded vid…

  17. What is the trade-off of cy.wait('@alias') vs implicit wait via .should?Mid

    `cy.wait('@alias')` waits for a *specific* request to complete — the right tool when you need to assert on the request/response or know t…

  18. How do you parameterise a test across multiple datasets in Cypress?Mid

    Use a plain `forEach` over the dataset, generating an `it` per case. Cypress doesn't have built-in parametrisation like `it.each` (Jest),…

  19. Why doesn't Cypress support multiple tabs natively, and what's the workaround?Mid

    Cypress's in-browser architecture binds a test to a single tab; spawning a second tab would require a second runner instance. The standar…

  20. Explain how cy.fixture() works and when to use it vs cy.intercept stubbing.Mid

    `cy.fixture('file')` loads a JSON/CSV/text file from `cypress/fixtures/` into your test. Combine with `cy.intercept` to stub network resp…

  21. How do you write a custom command in Cypress with TypeScript types?Mid

    Register the command with `Cypress.Commands.add(name, fn)` in `cypress/support/commands.ts`, then declare its type in a global `Cypress.C…

  22. What is component testing in Cypress and when would you use it over E2E?Mid

    Cypress component testing mounts a single component in isolation and tests it like a real browser — clicks, hovers, accessibility — witho…

  23. How do you handle iframes in Cypress?Mid

    Get the iframe element, drill into its document via `.its('0.contentDocument.body').then(cy.wrap)`, and continue chaining inside it. `cyp…

  24. How does Cypress retry failed tests, and what config options control this?Mid

    Cypress retries failed *tests* (not just commands) when configured via `retries`. Default is no retry; `{ runMode: 2, openMode: 0 }` is a…

  25. Explain the difference between cy.wrap and cy.then.Mid

    `cy.wrap(value)` puts a JavaScript value into the Cypress chain so you can run Cypress commands on it. `cy.then(fn)` pulls the *current s…

  26. How do you assert on a list of items in the DOM?Mid

    Use `cy.get(selector)` and assert on the count with `should('have.length', N)`, then iterate with `.each` to assert per-item, or extract…

  27. What's the cleanest way to test a multi-step form?Mid

    Encapsulate each step in a small page object or custom command, drive the happy path through them, and add per-step tests for validation…

  28. How do you mock the system clock in Cypress?Mid

    Use `cy.clock()` to override `Date.now`, `setTimeout`, and `setInterval` in the application's window. Advance time with `cy.tick(ms)`. Re…

  29. How do you handle file downloads in Cypress?Mid

    Cypress doesn't expose a download API. The pragmatic patterns: trigger the download and assert on the file in `cypress/downloads/` via `c…

  30. How do you test drag-and-drop interactions in Cypress?Mid

    Cypress doesn't have a native drag-and-drop command. For HTML5 drag/drop, fire `dragstart`, `drop`, `dragend` events with `cy.trigger`. F…

  31. What is cy.task and when is it the right tool?Mid

    `cy.task(name, args)` runs a Node-side function defined in `setupNodeEvents`. Use it for things the browser can't do: seeding the databas…

  32. How would you structure a Page Object Model in a TypeScript Cypress project?Mid

    Use a class or object per page with locators as private fields and actions as methods. Methods return `this` (or the next page) for chain…

  33. How do you handle conditional UI in Cypress (an element that may or may not appear)?Mid

    Don't use Cypress to branch on element existence — that fights retry-ability and produces flake. Either deterministically control whether…

  34. How does Cypress handle asynchronous code under the hood?Senior

    Cypress maintains an internal command queue. Each `cy.*` call appends to the queue synchronously, returning a chainable. After the test f…

  35. How would you architect a large Cypress test suite for a multi-team monorepo?Senior

    One Cypress install at the monorepo root, but tests organised by team or product area in their own folders. Share configuration via a bas…

  36. Walk me through how you'd debug a test that passes locally but fails in CI.Senior

    Reproduce the CI environment as closely as possible: same browser, headless mode, viewport, OS. Inspect the CI video, screenshot, and log…

  37. How do you handle authentication for tests that need different user roles?Senior

    Define one `cy.loginAs(role)` custom command backed by `cy.session(role, ...)` so each role logs in once per spec (or once across the sui…

  38. What's your strategy for keeping a 1000+ test suite under 30 minutes in CI?Senior

    Shard across N runners (Cypress Cloud or duration-balanced manual sharding), aggressively use `cy.session` and API login to skip UI auth,…

  39. How would you parallelise Cypress tests across CI machines without Cypress Cloud?Senior

    Generate a list of spec files, split it into N shards based on historical duration (or by file count as a fallback), and pass each shard…

  40. How do you handle visual regression in Cypress without a paid service?Senior

    Use `cypress-image-snapshot` or `cypress-visual-regression` to capture and diff PNGs in CI. Store baselines in git or an S3 bucket, fail…

  41. Compare cy.session caching across specs vs per-spec session caching.Senior

    Per-spec caching (default) re-runs login on the first test of each spec. `cacheAcrossSpecs: true` persists the session across the whole s…

  42. How would you test a real-time feature (WebSockets, SSE) in Cypress?Senior

    Cypress can intercept the WebSocket / EventSource handshake and stub server messages by injecting custom code into `onBeforeLoad`. For mo…

  43. What testability requirements would you push for as part of code review?Senior

    Stable test attributes (`data-test`) on every interactive element, deterministic IDs (no random UUIDs in DOM), no hard-coded `Date.now()`…

  44. How would you migrate a legacy Selenium suite to Cypress incrementally?Senior

    Don't rewrite all at once. Set up Cypress alongside Selenium, port the highest-ROI specs first (smoke, top user journeys), keep both runn…

  45. How do you handle environment-specific configuration in Cypress (dev/staging/prod)?Senior

    Use a single `cypress.config.ts` plus per-env overrides via env vars (`CYPRESS_baseUrl`, `CYPRESS_env_*`) or a small env-specific config…

  46. How do you set quality bars and metrics for an automation team owning Cypress?Lead

    Track flake rate (target <1%), CI duration (target <30 min), escape rate (production bugs not caught), and coverage of top user journeys…

  47. How would you justify the move to Cypress (or away from Cypress) to leadership?Lead

    Frame the choice in cost-benefit terms leadership cares about: developer time saved (faster feedback, easier debugging), maintenance cost…

  48. How do you handle disagreement between engineers on E2E test ownership — devs or QAs?Lead

    Frame it as shared ownership with clear responsibilities, not a binary handoff. Devs own unit + integration tests for the code they ship;…