Cypress interview questions
// 48 QUESTIONS · UPDATED MAY 2026
Cypress 13+ interview questions covering custom commands, sessions, intercept, retry-ability, component testing, and architecture decisions.
Showing 48 of 48 questions
- 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…
- 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…
- 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…
- 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…
- 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…
- 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 `…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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`…
- 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…
- 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…
- 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…
- 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…
- 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),…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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…
- 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,…
- 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…
- 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…
- 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…
- 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…
- 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()`…
- 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…
- 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…
- 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…
- 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…
- 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;…