Cypress Senior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

  1. 1. What is the main architectural trade-off of Cypress running inside the browser?

    Correct answer: Direct access to the app, but limits like one tab and same-origin rules

    Running in the browser gives time travel, app access and reliable waits. The cost is single-tab control, origin limits and JavaScript-only tests.

  2. 2. When would you choose Cypress over Playwright for a team?

    Correct answer: When the team values its interactive runner and the app fits its limits

    Cypress shines for single-app JS teams wanting fast feedback in the app runner. Multi-tab, multi-origin or multi-language needs favour Playwright.

  3. 3. Why does Cypress need cy.origin for SSO flows while Playwright doesn't?

    Correct answer: Cypress runs inside one origin's page and must switch context explicitly

    Playwright drives the browser from outside, so origins don't matter. Cypress runs in the page, so other origins need a separate execution context.

  4. 4. What is the most common root cause of flaky Cypress tests in large suites?

    Correct answer: Shared state and timing assumptions, like fixed waits or leaked data

    Most flakes trace to tests depending on each other, on real timing, or on shared backend data. Fix the cause; retries only hide it.

  5. 5. What does flaky test management in Cypress Cloud provide?

    Correct answer: Detection of tests that pass on retry, with history and trends

    Seeing which tests flake most, and since when, turns flakiness into a prioritised backlog.

  6. 6. What is a "burn-in" for new or changed tests?

    Correct answer: Running them many times before merge to catch flakes

    Repeating a new spec 10 or 20 times in CI exposes timing problems before they hit the main branch.

  7. 7. How should a team use test retries responsibly?

    Correct answer: Low retries in CI, tracking which tests pass only on retry

    Retries absorb rare infrastructure noise. Monitoring retried passes keeps real race conditions from being ignored.

  8. 8. What does Test Replay in Cypress Cloud help with?

    Correct answer: Debugging CI failures with DOM, network and console as they happened

    Instead of guessing from a screenshot, you inspect the recorded run like in the local app, which speeds up CI debugging.

  9. 9. How does Cypress Cloud balance specs across parallel machines?

    Correct answer: By past spec durations, giving each machine similar total time

    Duration-based balancing keeps the slowest machine short. Very long specs limit how well any balancing can work.

  10. 10. Why split very long spec files?

    Correct answer: One long spec sets a floor for parallel run time

    If one spec takes 12 minutes, no amount of parallelism finishes the run sooner. Smaller specs balance better.

  11. 11. How can you run only tests tagged @smoke in Cypress?

    Correct answer: Use the @cypress/grep plugin and filter by tag

    The grep plugin filters by title or tags and can skip specs with no matches, so smoke runs finish quickly.

  12. 12. What is a sensible test split between PRs and nightly runs?

    Correct answer: Fast critical set on PRs; full matrix and long flows nightly

    PRs need quick, trustworthy signals. Nightly runs catch cross-browser and slow-path problems, with clear owners for failures.

  13. 13. Why can heavy network stubbing make a Cypress suite give false confidence?

    Correct answer: Stubs can drift from the real API while tests stay green

    Pair stubbed UI tests with some tests against a real backend, or validate fixtures against the API contract.

  14. 14. How can fixtures be kept in sync with the real API?

    Correct answer: Generate or validate them against the schema or contracts

    Schema validation in CI fails when a fixture no longer matches the API, before UI tests silently test a fiction.

  15. 15. How should per-test database setup work in a parallel Cypress suite?

    Correct answer: Unique data per test via tasks or API, with cleanup

    Parallel machines hit the same backend. Unique IDs or tenants per test prevent collisions and order dependence.

  16. 16. What is a pitfall of cy.session without a validate function?

    Correct answer: Expired sessions get restored and tests fail later, confusingly

    Validation (e.g. checking a protected API returns 200) makes Cypress rebuild stale sessions automatically.

  17. 17. How would you test an app behind a third-party SSO provider?

    Correct answer: Programmatic login for most tests, plus a few full cy.origin flows

    Third-party pages are slow and change without notice. A test-only token endpoint or IdP keeps most tests fast and stable.

  18. 18. How should the balance between component and end-to-end tests be decided?

    Correct answer: Logic and states in component tests; key journeys in E2E

    Component tests cover many states quickly. E2E proves integration on critical paths.

  19. 19. What should a team consider when migrating from Cypress to Playwright?

    Correct answer: Rewrite effort, the command model differences, and run both during migration

    The chained command queue becomes await calls. Migrating specs gradually, highest value first, keeps coverage during the switch.

  20. 20. What makes a good custom command in a large Cypress codebase?

    Correct answer: Small, well-named, typed and doing one thing

    Large commands with many options become hard to reason about. Prefer composition of small commands and plain helper functions.

  21. 21. What does eslint-plugin-cypress help prevent?

    Correct answer: Anti-patterns like assigning results or unneeded waits

    Rules such as no-unnecessary-waiting and no-assigning-return-values catch common mistakes in review automatically.

  22. 22. How should a monorepo with several apps organise Cypress?

    Correct answer: A config per app with its own baseUrl, specs and CI job

    Per-app configs keep servers and data separate, and CI can test only apps affected by a change.

  23. 23. Why run Cypress against preview deployments per pull request?

    Correct answer: Bugs are found before merge, on the exact build and infrastructure

    Pointing baseUrl at the preview URL tests what will ship, including build and config differences.

  24. 24. What does numTestsKeptInMemory affect?

    Correct answer: How many tests keep snapshots in memory in the app runner

    Snapshots enable time travel but use memory. Long specs in open mode may crash without lowering it; in run mode it's usually 0.

  25. 25. Why might you turn off video recording in CI?

    Correct answer: It costs time and storage; screenshots often suffice

    Many teams record video only on failure or rely on Test Replay instead.

  26. 26. How can third-party scripts like chat widgets make Cypress tests flaky?

    Correct answer: They load slowly or cover elements; block them with blockHosts

    Blocking analytics and widgets removes noise. A separate test can verify the integration itself.

  27. 27. What is the risk of setting chromeWebSecurity: false?

    Correct answer: Tests may pass in conditions real browsers would block

    Turning off same-origin checks hides real CORS or iframe problems. Prefer cy.origin or fixing the setup.

  28. 28. Why are WebSocket features harder to test in Cypress?

    Correct answer: cy.intercept doesn't stub WebSocket traffic

    Teams stub the socket client in the app, use a test server, or test the real connection with assertions on the UI.

  29. 29. How do service workers interfere with Cypress network stubbing?

    Correct answer: Requests served by the worker bypass cy.intercept

    Unregister service workers in tests, or disable them in test builds, so stubs behave predictably.

  30. 30. How do you make date-dependent tests stable across time zones?

    Correct answer: Control TZ in CI and freeze time with cy.clock

    Setting the time zone of the browser process and a fixed clock makes "today" and DST edges deterministic.

  31. 31. How should feature flags be handled in Cypress tests?

    Correct answer: Set flags per test, e.g. via API or intercepted config

    Controlling the flag makes both paths testable and stops tests failing when someone toggles a shared flag.

  32. 32. What does experimentalMemoryManagement address?

    Correct answer: Browser memory problems in long Chromium-based runs

    Large suites can crash the browser. Memory management options and smaller specs help keep runs stable.

  33. 33. Which reporting setup works well for Cypress in CI dashboards?

    Correct answer: JUnit or multi-reporters merged per run, plus artifacts

    JUnit XML shows results in merge requests; HTML reports like mochawesome help humans browse failures.

  34. 34. How do you test across browsers without slowing every PR?

    Correct answer: Run Chrome on PRs and the full browser matrix nightly

    Most bugs show in one browser. Engine-specific issues are caught nightly with clear owners for failures.

  35. 35. What are the limits of mobile testing with cy.viewport?

    Correct answer: Only size changes; touch, engines and devices aren't real

    Use viewport tests for responsive layout; real-device testing covers mobile browsers and gestures.

  36. 36. How can accessibility checks be enforced in a Cypress suite?

    Correct answer: Run cypress-axe on key pages in CI with agreed rules

    Automated checks catch many issues early; a team rule set and allowed exceptions keep results actionable.

  37. 37. Is gating merges on Cypress code coverage a good idea?

    Correct answer: Use coverage to find gaps, not as a hard target

    E2E coverage is coarse. Targets encourage tests written for numbers instead of behaviour.

  38. 38. How should test accounts used by Cypress be secured?

    Correct answer: Least privilege, separate from production, secrets from CI vault

    Leaked test credentials shouldn't open production data. Rotate them and keep them out of the repository.

  39. 39. What makes a Cypress suite hard to maintain over time?

    Correct answer: Fragile selectors, long specs and setup through the UI

    Stable selectors, short independent tests and direct setup keep maintenance cost low.

  40. 40. How do you decide which flows deserve Cypress E2E coverage?

    Correct answer: By business risk and how often the flow breaks

    Checkout and login are worth it; rarely used admin screens may need only smoke checks.

  41. 41. What metric best shows whether the Cypress suite helps the team?

    Correct answer: Escaped defects and time to diagnose failures

    A suite that catches bugs before release and fails clearly is worth its cost; a noisy one gets ignored.

  42. 42. How should tests interact with apps that use heavy client-side routing?

    Correct answer: Assert on content of the new route, not on fixed waits

    Client-side routes change without page loads. Assert on URL and visible content to sync.

  43. 43. Why should you avoid cy.wait on a fixed number before an assertion even in CI-only tests?

    Correct answer: CI timing varies more than local timing

    Shared runners are slower and noisier. Conditional waits adapt; fixed ones become flaky or slow.

  44. 44. How do you test that an API error shows a friendly message without a real failing backend?

    Correct answer: Stub the endpoint with an error status and assert the UI

    cy.intercept(..., { statusCode: 500 }) tests error states deterministically without affecting others.

  45. 45. Why keep assertions in tests rather than inside custom commands?

    Correct answer: Readers see what each test verifies

    Commands are good for actions and setup. Hidden checks make failures surprising and tests harder to read.

  46. 46. What happens when tests share one user whose data changes?

    Correct answer: Parallel runs collide and results depend on order

    Per-test users or resetting data via tasks keeps tests independent.

  47. 47. What is a good approach to testing emails sent by the app?

    Correct answer: Use a test mail server API and read messages via cy.request

    Tools like Mailpit expose an API, so tests fetch the message, extract the link and continue.

  48. 48. How can Cypress tests verify analytics events without real tracking?

    Correct answer: Intercept tracking calls and assert their payloads

    Stubbing tracking endpoints keeps data clean and checks the right events and properties fire.

  49. 49. What is the trade-off of Cypress's automatic waiting for page loads?

    Correct answer: Convenient, but long-polling or slow loads can hit page timeouts

    Apps that never fire load quickly need tuned pageLoadTimeout or a fix in the app's loading strategy.

  50. 50. How do you keep a Cypress suite's run time in check as it grows?

    Correct answer: Track spec durations, parallelize, and move checks to lower levels

    Duration trends show which specs slow down. Logic checks often belong in unit or component tests.

  51. 51. Why should Cypress tests not depend on production-like data in staging?

    Correct answer: Shared data changes unpredictably and breaks tests

    Seeded, owned data makes results repeatable regardless of what others do in the environment.

  52. 52. How should you handle a known bug that makes a test fail?

    Correct answer: Skip it with a linked ticket until it's fixed

    Skips with ticket links (or expected-failure tags) keep the problem visible without blocking every pipeline.

  53. 53. What should a review of a new Cypress test look for?

    Correct answer: Isolation, stable selectors, no fixed waits, meaningful assertions

    Review catches flakiness before it spreads, like any production code.

  54. 54. How do you test file uploads to cloud storage with signed URLs?

    Correct answer: Intercept the upload, assert it, and stub storage replies

    Stubbing the storage call keeps tests fast and avoids costs; one integration test can cover the real path.

  55. 55. Why may a Cypress test pass locally but fail in CI with the same code?

    Correct answer: Different speed, screen size, data or env config

    Matching viewport, browser, env values and data in both places, plus CI artifacts, narrows the cause.

  56. 56. What is the benefit of running the same suite against several locales?

    Correct answer: Catches untranslated text, overflow and format bugs

    Configure locale via env or URL, and keep selectors language-independent with data-cy.

  57. 57. How should network-heavy dashboards be tested to stay fast?

    Correct answer: Stub most data calls with fixtures and test real calls separately

    Fixture-driven tests cover rendering states; a few integration tests ensure the real API wiring works.

  58. 58. What is a sign that a Cypress suite has too much E2E coverage?

    Correct answer: Slow runs testing logic better covered in unit tests

    When E2E tests check every validation rule, move those to unit or component tests and keep E2E for flows.

  59. 59. How do you test permissions for many roles efficiently?

    Correct answer: Parameterize tests over roles, logging in programmatically

    Loops over roles with cy.session per role check visible features and denied actions quickly.

  60. 60. What does Cypress.on('uncaught:exception') returning false do, and why use it carefully?

    Correct answer: Ignores app errors; overusing it hides real bugs

    Ignore only specific known third-party errors by message, never all exceptions.

  61. 61. How do you test long-running background jobs triggered from the UI?

    Correct answer: Poll the status via cy.request or UI with a timeout

    Retrying assertions or a polling task wait just long enough and fail clearly if the job never finishes.

  62. 62. What does a stable selector policy for a team look like?

    Correct answer: data-cy for test hooks, roles for accessible elements

    A written policy keeps selectors consistent and tells developers not to remove test attributes.

  63. 63. How can Cypress catch hydration or runtime errors that don't break visible UI?

    Correct answer: Fail on uncaught exceptions and spy on console.error

    Such errors often precede visible bugs. Surfacing them in CI catches regressions early.

  64. 64. What should happen when a Cypress test is consistently slow?

    Correct answer: Profile its steps; remove UI setup and real waits

    The command log and Test Replay show where time goes, usually logins, unstubbed calls or waits.

  65. 65. How do you test a drag-and-drop UI in Cypress?

    Correct answer: Trigger mouse or drag events, or use a plugin

    .trigger('mousedown'), mousemove, mouseup or a drag plugin, depending on how the library listens for events.

  66. 66. When is testing a canvas-based UI in Cypress practical?

    Correct answer: Through app state, test hooks or visual comparisons

    Canvas content isn't in the DOM. Expose state for assertions or use screenshot diffs for visual checks.

  67. 67. How should Cypress tests handle randomness in the app, like shuffled lists?

    Correct answer: Seed or stub the randomness for stable output

    Stub Math.random in onBeforeLoad or set a seed via config to make tests repeatable.

  68. 68. What is a risk of very large fixtures?

    Correct answer: They hide what matters and slow tests down

    Small fixtures focused on the test case are easier to read and update.

  69. 69. How do you check that sensitive data isn't stored in localStorage?

    Correct answer: Inspect localStorage after login and assert absence

    Tokens or personal data in localStorage are exposed to XSS. A quick assertion guards against regressions.

  70. 70. How can you prevent tests from accidentally hitting production?

    Correct answer: Guard in config: fail if baseUrl matches production

    A check in setupNodeEvents that throws on a production URL avoids costly mistakes.

  71. 71. What is a healthy ownership model for E2E tests?

    Correct answer: Feature teams own their specs and fix failures fast

    Ownership with clear routing of failures keeps the suite trusted.

  72. 72. How do you test that an app works with slow 3G-like networks?

    Correct answer: Throttle with intercept delays or browser settings

    Delays and bandwidth limits on key requests show loading states and timeouts.

  73. 73. Why is testing inside Electron (the default) not always enough?

    Correct answer: Users run Chrome, Firefox or Safari, which differ

    Run important flows in the browsers your users actually use, at least nightly.

  74. 74. What is the main risk of using cy.task to read the database directly in assertions?

    Correct answer: Tests couple to schema details instead of behaviour

    Prefer checking outcomes through the UI or API; use direct DB checks sparingly for side effects that aren't visible.

  75. 75. How should screenshots from failing tests be handled for privacy?

    Correct answer: Avoid real personal data and restrict artifact access

    Test data should be synthetic, and CI artifacts should follow the same access rules as other internal data.

  76. 76. When does a dedicated API test suite beat cy.request tests?

    Correct answer: For large API coverage needing contracts, load and schemas

    Cypress can test APIs, but dedicated tools fit large API suites better. Use Cypress API calls mainly for setup.