QA Interview
Cypress Test Isolation Debugging Interview Questions (2026)
Prepare Cypress test isolation debugging interview questions with 48 scenario answers on state leaks, sessions, retries, network control, and CI evidence.
25 min read | 3,982 words
TL;DR
Expect interviewers to test whether you can separate browser cleanup from backend data isolation, use cy.session() without hiding dependencies, and diagnose order-sensitive or CI-only failures from evidence. The best answers name the leaking state, propose a controlled experiment, and describe a permanent fix rather than masking the symptom with waits or retries.
Key Takeaways
- Test isolation removes browser context between end-to-end tests, while Cypress also resets aliases, intercepts, spies, stubs, clocks, and viewport changes.
- A strong diagnosis proves the leaking state channel by running one test alone, reversing order, and inspecting browser, server, and network state.
- Use cy.session() to cache validated authentication state, then call cy.visit() because an isolated session can leave the page at about:blank.
- Keep backend records, accounts, inboxes, and files unique per test because browser cleanup cannot isolate server-side resources.
- Cypress retries linked queries and assertions, but it does not repeat action commands or .then() callbacks.
- Preserve videos, screenshots, command logs, network details, browser versions, and seed identifiers to make CI-only failures reproducible.
- Disable test isolation only for a deliberate end-to-end workflow with explicit ownership and proof that individual tests still work independently.
Cypress test isolation debugging interview questions test more than your memory of testIsolation: true. Interviewers want to hear how you identify the exact state channel, reproduce an order-dependent failure, preserve useful evidence, and redesign a suite so every test passes alone or in any order.
This guide gives you 48 scenario-based questions with concise model answers. Use the topic map to find weak areas, run the code against a test application, then rehearse the diagnosis aloud in Cypress mock interview practice. For broader framework preparation, pair this guide with Cypress interview questions.
TL;DR
| Topic | What a strong answer proves | First diagnostic move |
|---|---|---|
| Browser isolation | You know what Cypress resets and when | Run the test alone, then after its suspected polluter |
| Authentication | You can cache login without sharing page state | Inspect the cy.session() key, setup, and validation |
| Network control | You distinguish an absent request from a bad route matcher | Register the intercept before the triggering action |
| Backend data | You understand that browser cleanup cannot erase server records | Trace the test's unique data identifier through API logs |
| Retryability | You separate retried queries from one-time actions | Break the chain at the action and re-query the DOM |
| CI debugging | You collect enough evidence to reproduce the same environment | Match browser, spec order, shard, seed, and configuration |
A useful answer follows a compact sequence: name the suspected state, design one experiment that can disprove the theory, inspect the evidence, then make the setup deterministic. The detailed Cypress retry-ability guide is a helpful companion when the failure involves rendering rather than leaked state.
Interview Questions and Answers
The questions below progress from core mechanics to senior debugging trade-offs. Each answer is written as a model you can adapt to a real incident from your own suite.
1. Cypress test isolation debugging interview questions: core model
Q: What does test isolation mean in Cypress end-to-end testing?
With test isolation enabled, Cypress visits about:blank and clears cookies, local storage, and session storage across domains before each end-to-end test. It also resets test slate items such as aliases, intercepts, spies, stubs, clock mocks, and viewport changes. The outcome is that an it block must establish its own page and required state instead of inheriting them from the previous test.
Q: Is test isolation the same as clearing the browser cache?
No. The isolation contract clears the page, cookies, local storage, and session storage, but a resource already served from the browser cache may never reach the network layer. If cy.intercept() does not observe a cached request, inspect DevTools and control cache headers in the test environment. Do not claim that testIsolation: true guarantees an empty HTTP cache.
Q: Which Cypress objects are reset even when testIsolation is false?
Aliases, intercepts, spies, stubs, clock mocks, and viewport changes are restored before every test as part of Cypress's clean test slate. Setting testIsolation: false preserves the current page and browser storage, not those Cypress-managed objects. Therefore an alias created in one it block cannot safely be consumed in another.
Q: How would you prove a test is genuinely independent?
Run the test alone with .only(), then run its full spec and reverse the two tests most likely to interact. Repeat with the candidate polluter skipped so the comparison changes one variable at a time. Independence is demonstrated when the result remains stable without relying on order, retained browser state, or records created by another test.
The default should be explicit in configuration:
// cypress.config.ts
import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
testIsolation: true,
specPattern: 'cypress/e2e/**/*.cy.ts',
},
})
Verify the configuration and one spec with npx cypress run --spec cypress/e2e/isolation.cy.ts.
2. Find order-dependent state leaks
Q: A test passes alone but fails after another test. What do you inspect first?
Treat the preceding test as a polluter, not as proof of the root cause. Compare cookies, storage keys, server records, feature flags, clock state, and route behavior immediately after each setup. Then build a two-test reproduction containing only the polluter and victim so every additional observation has a clear meaning.
Q: How do you distinguish a browser leak from a backend data collision?
Start the victim with a new browser context but reuse the same API data identifier. If it still fails, the likely channel is server state, a shared account, a queue, or a cache outside Cypress's browser cleanup. If a unique identifier fixes it while the browser setup remains unchanged, you have evidence of a backend collision rather than a storage leak.
Q: Why is randomizing spec order useful but insufficient?
Random order reveals hidden dependencies by exercising combinations your normal run never reaches. A passing randomized run does not prove independence because it samples only some orders and timing conditions. Record the seed, minimize a failing order to the smallest polluter-victim pair, and fix the shared resource rather than keeping randomization as the only defense.
Q: What is a practical way to bisect a large failing suite?
Keep the victim fixed and run it after half of the suspected tests. Select the half that reproduces the failure and repeat until one polluter remains. This binary-search approach reduces noisy reruns, but you should still examine global hooks and Node event handlers because they can affect every subset.
A passing isolated example creates its own data in beforeEach and removes it after the assertion:
// cypress/e2e/isolation.cy.ts
describe('project isolation', () => {
let projectId: string
beforeEach(() => {
cy.request('POST', '/api/test/projects', { name: `project-${Date.now()}` })
.its('body.id')
.then((id: string) => {
projectId = id
})
})
afterEach(() => {
cy.request('DELETE', `/api/test/projects/${projectId}`)
})
it('opens its own project', () => {
cy.visit(`/projects/${projectId}`)
cy.get('[data-cy=project-id]').should('have.text', projectId)
})
})
Run npx cypress run --spec cypress/e2e/isolation.cy.ts twice. Both executions should pass with different project IDs.
3. Hooks, setup, and cleanup boundaries
Q: When should setup go in beforeEach instead of before?
Use beforeEach when every test needs a fresh user, record, session restoration, or page visit. A before hook creates state once, so later tests can silently depend on mutations made by earlier tests. Reserve it for immutable suite-level preparation whose output is not consumed or changed as shared test state.
Q: Why can afterEach cleanup make failures harder to debug?
Cleanup may delete the exact record, file, or message needed to understand the failure. It can also fail after the test and blur whether the assertion or teardown caused the red result. Prefer unique disposable data, preserve identifiers in logs, and move guaranteed environment cleanup to an API or scheduled process when post-failure inspection matters.
Q: Should a test use the UI or an API to create prerequisites?
Use direct API setup for facts the test is not evaluating, such as an existing customer or paid subscription. Use the UI for the behavior under test so the assertion still covers the user journey that carries risk. This split shortens setup, reduces unrelated failure points, and leaves one clear action path to diagnose.
Q: How do you prevent a failed beforeEach from obscuring the real problem?
Keep the hook small and assert the response that establishes each prerequisite. Give setup requests descriptive aliases or log the generated entity ID so the first broken boundary is visible. If setup has several business steps, wrap them in one test-support API rather than scattering commands across nested hooks.
For a reusable framework structure, see how to build a Cypress framework from scratch, but keep helpers observable and narrowly scoped.
4. Authentication and cy.session()
Q: What problem does cy.session() solve?
cy.session() caches and restores cookies, local storage, and session storage produced by a setup callback. It avoids repeating an expensive login while retaining an isolated starting point for each test. It does not preserve the DOM, aliases, intercepts, or arbitrary in-memory JavaScript state.
Q: What belongs in a cy.session() identifier?
Include every input that changes the resulting authenticated state, such as username, tenant, role, locale, or authentication strategy. Two personas must not resolve to the same key because Cypress could restore valid storage for the wrong authorization context. Avoid placing secrets in a human-readable ID when a stable non-secret account label can distinguish the session.
Q: Why should a session have a validate callback?
A cached cookie can exist after the server session expires or the user's permissions change. The validate callback should make a cheap authenticated request or assert a trustworthy storage condition, causing Cypress to rerun setup when validation fails. A UI-only check after visiting a page is slower and may mistake a cached shell for authenticated access.
Q: Why is the page blank after cy.session()?
With test isolation enabled, Cypress clears the page while establishing or restoring a session, so the current document can be about:blank. Call cy.visit() after cy.session() in the test or beforeEach. Treating session restoration as navigation couples two different responsibilities and often causes this interview scenario.
This spec defines the session, validates it through an authenticated endpoint, and visits after restoration:
// cypress/e2e/session.cy.ts
const loginAs = (role: 'admin' | 'viewer') => {
cy.session(['api-login', role], () => {
cy.request('POST', '/api/test/login', { role })
.its('status')
.should('eq', 200)
}, {
validate() {
cy.request('/api/me').its('body.role').should('eq', role)
},
})
}
describe('role sessions', () => {
beforeEach(() => {
loginAs('admin')
cy.visit('/admin')
})
it('shows the admin heading', () => {
cy.contains('h1', 'Administration').should('be.visible')
})
})
Verify with npx cypress run --spec cypress/e2e/session.cy.ts. Learn the cache lifecycle in the focused cy.session guide.
5. Cookies, storage, origins, and time
Q: How do you debug a localStorage value that unexpectedly disappears?
Check whether the read occurs in a new test, after cy.session(), or on a different origin from the write. Log the origin and key inside cy.window().then() rather than assuming DevTools is showing the same browsing context. Restore intentional state in beforeEach or through a validated session instead of disabling isolation globally.
Q: Can one test preserve a consent cookie without disabling test isolation?
Yes. If the value is known, call cy.setCookie('cookieConsent', 'accepted') in beforeEach before visiting the application. If the server generates it through a flow, cache that flow with cy.session() and validate the result. Both approaches express the prerequisite without retaining an entire page between tests.
Q: What changes when the application uses multiple origins?
Browser storage is scoped by origin, while Cypress clears cookies and web storage across domains when isolation is enabled. Interactive commands on a secondary top-level origin belong inside cy.origin() with serializable arguments. Your session key and validation must account for the identity provider and application state rather than assuming one origin owns the whole login.
Q: How can a frozen clock leak or mislead a later assertion?
Cypress restores clock mocks between tests, but application records written with a frozen timestamp can remain on the server. A later test may then sort or expire those records using real time and fail unexpectedly. Use unique records, state the clock boundary explicitly, and reset backend time controls separately from cy.clock().
6. Network intercept isolation
Q: Why does an intercept created in one test not work in the next?
Cypress automatically clears intercepts before every test, regardless of the testIsolation setting. Register the route in the same test or its beforeEach, before the action that sends the request. Reusing only the alias name does not recreate the route matcher.
Q: cy.wait('@users') times out. What sequence do you investigate?
First confirm the intercept is registered before cy.visit() or the click that triggers the request. Then compare method, hostname, pathname, query, and the actual URL in the browser Network panel. Finally check whether the response came from browser cache, because a request that never reaches the network layer cannot match cy.intercept().
Q: How do you avoid one broad intercept masking unrelated calls?
Match the HTTP method and the narrowest stable pathname or query properties required by the scenario. Give distinct aliases to reads and mutations instead of using one **/api/** rule. When handler order matters, explain the default reverse matching order and use { middleware: true } only when defined-order processing is intentional.
Q: How would you stub only the first request and allow later traffic?
Use a route matcher with times: 1 and a static response for the exceptional first call. A second, broader spy can observe subsequent real requests if the scenario needs both behaviors. This models a transient failure without maintaining mutable counters outside Cypress's routing API.
// cypress/e2e/network-isolation.cy.ts
describe('network isolation', () => {
beforeEach(() => {
cy.intercept({ method: 'GET', pathname: '/api/profile', times: 1 }, {
statusCode: 503,
body: { error: 'temporary' },
}).as('firstProfile')
})
it('shows a retry action after a transient error', () => {
cy.visit('/profile')
cy.wait('@firstProfile').its('response.statusCode').should('eq', 503)
cy.contains('button', 'Retry').should('be.visible')
})
})
Verify with npx cypress run --spec cypress/e2e/network-isolation.cy.ts. For deeper route-matching scenarios, review Cypress cy.intercept examples and network interception interview questions.
7. Backend data and parallel workers
Q: Why can isolated browser tests still fail in parallel?
Workers can share a database row, account, email inbox, object-storage key, rate limit, or downstream sandbox. Cypress resets each browser context but cannot partition those external resources. Generate worker-safe identifiers and make setup and cleanup APIs idempotent so concurrency does not change the result.
Q: What makes a test-data identifier safe for parallel execution?
Combine a run identifier with the spec or test identity and a random suffix, then pass it through every created resource. Do not rely on Date.now() alone because workers can execute within the same millisecond. Log the identifier once so a CI artifact can be correlated with backend traces and teardown records.
Q: How do shared user accounts create flakiness?
One test may change the password, role, cart, locale, or active session while another assumes the default profile. Logout behavior can also invalidate tokens used by a parallel worker. Allocate accounts by scenario or create users through an API, and avoid tests whose assertion depends on an untouched global account.
Q: What should cleanup do when a test is retried?
Setup should tolerate the resource already existing or should create a new attempt-scoped resource. Cleanup should accept an absent resource and remove all children tied to the run identifier. This idempotency prevents a first failed attempt from poisoning the retry with partial server state.
Use the strategy in Cypress parallelization examples when moving an isolated local suite onto multiple CI machines.
8. Retryability, actions, and detached DOM
Q: Which Cypress operations retry automatically?
Linked queries retry from the top of their query chain, and assertions are queries with special reporting. Non-query commands execute once, while action commands wait for actionability but do not repeat the click or type after execution. This distinction explains why adding assertions helps rendering waits but cannot safely repeat a side effect.
Q: Why can .then() cause a timing failure?
A .then() callback runs once after its preceding command resolves. Values derived inside it are not recomputed when a later assertion fails, so a changing DOM value can be captured too early. Put retry-safe calculations inside .should(callback) when you need Cypress to query and evaluate again.
Q: How do you fix a detached element after a click?
End the chain at the action, then issue a fresh query for the next assertion or interaction. Framework rerenders can replace the original node, leaving a chained subject attached to an obsolete element. Stable data-cy selectors help locate the new node, but they do not make a stale reference current.
Q: Is increasing defaultCommandTimeout a good flake fix?
Only when the product has a known, acceptable latency and the assertion is waiting on the correct observable condition. A global increase slows every missing-element failure and can hide an absent request or incorrect setup. Prefer an alias for the relevant request, a domain assertion, or a narrowly scoped timeout with a documented reason.
// cypress/e2e/retryable-total.cy.ts
describe('retryable rendering', () => {
it('waits until a numeric total is positive', () => {
cy.visit('/cart')
cy.get('[data-cy=total]').should(($total) => {
const amount = Number($total.text().replace(/[^0-9.]/g, ''))
expect(amount).to.be.greaterThan(0)
})
})
})
Verify with npx cypress run --spec cypress/e2e/retryable-total.cy.ts. This callback is safe because it contains assertions and no side effects.
9. Interactive debugging tools
Q: When would you use .debug() instead of cy.pause()?
Use .debug() on a command chain when you need the current subject printed and want the browser debugger to stop at that point. Use cy.pause() when you want to advance through queued Cypress commands interactively and inspect state between them. Both are local investigation tools and should be removed before committing the spec.
Q: Why can a plain debugger statement appear to run too early?
Cypress queues commands, while the JavaScript containing a top-level debugger continues synchronously during test definition or command scheduling. Place it inside .then() after the command whose state you need, or use .debug() on that subject. This aligns the breakpoint with Cypress's execution queue.
Q: What does command time travel reveal?
Selecting a command in the runner shows a snapshot of the application around that command and exposes its subject or yielded result in DevTools. Compare the snapshot before the failure with the live DOM, because the application may have rerendered since Cypress captured it. The distinction often exposes a detached subject, wrong selector scope, or unexpected navigation.
Q: How do you debug an application error that fails the test?
Read the original stack and browser console before considering an exception handler. Reproduce the same user action outside the test and determine whether the product or test setup caused the error. A global uncaught:exception handler that always returns false suppresses real defects, so any narrow exception policy needs a named, reviewed reason.
For an editor-driven workflow, use debugging a failing Cypress test in VS Code.
10. CI-only failures and evidence
Q: A test passes headed but fails headless. What do you compare?
Compare browser family and version, viewport, environment variables, CPU pressure, locale, timezone, reduced-motion behavior, and whether the server build is identical. Run the failing CI command locally before changing the test. Then vary one dimension at a time so a browser-specific rendering issue is not mislabeled as generic flake.
Q: Which artifacts should a CI run preserve?
Keep the failure screenshot, video when enabled, console and server logs, Cypress configuration, browser version, spec and shard identity, retry attempt, and the test-data ID. Network request and response metadata is particularly valuable when the DOM merely reflects an upstream error. Apply retention and redaction rules so evidence does not expose credentials or personal data.
Q: How do retries help diagnosis without becoming a mask?
A retry establishes that the result is nondeterministic and can preserve evidence from multiple attempts. It does not make the first failure acceptable or identify the leaking channel. Track attempt-level outcomes, assign an owner, and remove or reduce retries after the underlying synchronization or state problem is fixed.
Q: How do you reproduce a failure from one parallel shard?
Record the exact spec list, machine index, browser, environment, and data seed for that shard. Re-run the same spec with the same backend environment and account allocation before recreating the full pipeline. If the issue requires a neighbor spec, use the recorded order to form a minimal polluter-victim pair.
The Cypress handling flaky tests guide expands the evidence-to-fix workflow beyond isolation defects.
11. Configuration and component-test boundaries
Q: Can testIsolation be overridden for one suite?
End-to-end suites can set { testIsolation: false } on a describe block when preserving browser context is an explicit design choice. Keep the override narrow, document the workflow that requires it, and verify each test with .only() before accepting the trade-off. A global disable converts hidden dependencies into suite architecture.
Q: Does component testing support configurable test isolation?
No. Cypress component testing always resets its browser context, including unmounting the component and clearing cookies plus local and session storage. If component tests interact unexpectedly, inspect module singletons, application stores, fake servers, and cleanup performed by the mounting adapter rather than searching for an end-to-end testIsolation toggle.
Q: When is disabling isolation defensible?
A deliberately ordered, stateful end-to-end workflow may use it when the workflow itself is the tested unit and splitting it would destroy its meaning. That suite should be small, serial, clearly labeled, and excluded from claims that every it is independent. Most login or setup performance complaints are better solved with API setup and cy.session().
Q: What risk appears when nested suites use different isolation settings?
Readers can no longer infer the browser starting state from the file alone, and moving a test changes its behavior. Hooks may run under assumptions established by a parent suite while a nested suite preserves the page. Prefer one obvious boundary with a comment explaining ownership, and avoid clever nesting around stateful flows.
12. Cypress test isolation debugging interview questions: senior scenarios
Q: How would you debug a test that fails only after logout coverage?
Inspect whether logout invalidates all tokens for a shared account, not only the current browser cookie. Run the victim with a separate user while keeping spec order unchanged; a pass implicates shared server identity. Fix account allocation or token scoping instead of restoring a cookie that the backend has already revoked.
Q: A test fails only on Monday after a weekend. What state channels do you suspect?
Check expired cached sessions, date-bound fixtures, retained database rows, rotating secrets, scheduled jobs, and timezone assumptions. Recreate the clock and data age independently to see which boundary triggers the failure. The calendar correlation is evidence, but the answer should name a falsifiable experiment rather than blame CI timing.
Q: How would you migrate a dependent ten-test checkout flow?
Identify the business state each test actually asserts, then create that state directly through APIs or fixtures in beforeEach. Keep one complete happy-path test for cross-step integration and turn the remaining cases into independent scenarios starting at the nearest stable boundary. Measure runtime and failure localization before and after so the migration proves operational value.
Q: How do you explain an isolation incident to developers and managers?
Describe the leaking resource, the smallest reproducing order, and the user-facing behavior that the victim test was meant to protect. Separate the immediate containment, such as allocating unique accounts, from the permanent framework change and ownership. Report retry rates or wasted reruns only from observed pipeline data, never from invented estimates.
How Interviewers Grade Your Answers
Interviewers usually score four signals. First, you must name Cypress behavior precisely: browser context is not backend state, queries retry but actions do not, and intercepts reset per test. Second, your experiment should change one variable and be capable of disproving your initial theory.
Third, strong answers connect the local symptom to parallel workers, identity providers, databases, queues, or cached responses. Fourth, the proposed fix should improve determinism without erasing evidence. A response like "I add a wait and rerun" is weak because it neither identifies a boundary nor establishes why the wait represents product readiness.
Use a real incident story with this structure: symptom, smallest reproduction, evidence, root cause, change, and verification. Practice delivering it in two minutes, then use the QAJobFit dashboard to align the example with the skills named in your resume.
Common Mistakes
- Disabling
testIsolationglobally because repeated login feels slow. Cache authenticated storage withcy.session()and validate it instead. - Assuming browser cleanup removes database rows, inbox messages, queue jobs, files, or third-party sandbox state. Give each test its own external resources.
- Creating aliases or intercepts in
beforeand expecting them to survive everyit. Register them inbeforeEach. - Calling
cy.wait(5000)without identifying the event that makes the application ready. Wait on a request alias or assert a domain state. - Putting side effects inside
.should(callback). Cypress can rerun that callback, so keep it limited to calculations and assertions. - Capturing a DOM node in
.then()and reusing it after an action triggers a rerender. End the chain and query again. - Sharing one mutable account across parallel shards. Allocate identities by role and run, then clean them idempotently.
- Suppressing all uncaught exceptions. Investigate the application error and narrow any accepted exception to a reviewed case.
- Reporting a retry pass as a fix. Preserve both attempts and remove the nondeterministic state channel.
- Deleting failed test data before recording its identifier. Make evidence correlation part of teardown design.
Conclusion
The best answers to Cypress test isolation debugging interview questions combine exact runner behavior with disciplined experiments. Explain what Cypress clears, what it cannot clear, how you reproduce the failure, and which evidence proves the root cause.
Choose three scenarios from this guide and answer them using incidents from your own framework. Then run the examples, vary their order or data, and practice defending each trade-off under follow-up questions.
Interview Questions and Answers
What exactly does Cypress reset between end-to-end tests?
Cypress resets aliases, intercepts, spies, stubs, clock mocks, and viewport changes before every test. With test isolation enabled, it also visits about:blank and clears cookies, local storage, and session storage across domains. It does not clean database rows or other external systems.
How do you diagnose an order-dependent Cypress failure?
I run the victim alone, after its suspected polluter, and with that polluter skipped. I compare browser storage, server records, account state, and network behavior, changing one channel per experiment. Then I reduce the suite to the smallest order that still reproduces the problem.
When do you use cy.session()?
I use cy.session() to cache authenticated cookies and web storage so tests avoid repeating login. The identifier includes all inputs that alter identity, and validate checks an authenticated endpoint. I still visit the target page after restoration.
Why does cy.wait() time out for an intercept alias?
The intercept may have been registered after the request, its method or URL matcher may be wrong, or the browser may have served the resource from cache. I inspect the Network panel and Cypress route table before widening the matcher. Intercepts are recreated in beforeEach because Cypress clears them per test.
How do you isolate test data across parallel Cypress workers?
I combine a run ID, test identity, and random suffix to create unique users and records. Setup and cleanup endpoints are idempotent, and the identifier is logged for correlation. Shared accounts are allocated by scenario rather than reused globally.
What is the difference between Cypress retryability and test retries?
Retryability repeatedly evaluates linked queries and assertions until their timeout, while non-query actions execute once. Test retries rerun an entire failed test according to configuration. The former synchronizes observable UI state, while the latter supplies evidence of nondeterminism but does not fix it.
How do you fix a detached DOM element failure?
I end the command chain after the action that can trigger a rerender and query the element again. Reusing a subject captured before the rerender points at an obsolete node. I also verify that the selector identifies stable application intent.
When would you set testIsolation to false?
Only for a small, explicitly ordered end-to-end workflow where preserved browser context is part of the tested unit. I document the boundary, keep it serial, and verify the trade-off. Authentication performance alone is not enough because API setup and cy.session() preserve independence.
What evidence do you retain for a CI-only Cypress failure?
I retain screenshots, video when enabled, browser version, Cypress configuration, console and server logs, network metadata, spec order, shard identity, retry attempt, and data seed. Those artifacts let me recreate both the browser environment and external state. Sensitive values are redacted under the team's retention policy.
Why is a fixed cy.wait() weak debugging practice?
A fixed delay does not identify the readiness condition and adds time even when the application is ready. It can temporarily hide incorrect setup, an absent request, or a race. I wait on a precise request alias or assert the domain state the user actually needs.
How do component tests handle isolation?
Cypress component testing always unmounts the component and clears cookies, local storage, and session storage before each test. It does not support configuring test isolation like end-to-end testing. Remaining leaks often come from imported singletons, stores, or fake servers.
How do you communicate the root cause of an isolation defect?
I name the leaking resource, show the minimal polluter-victim order, and connect it to the behavior under test. I separate immediate containment from the permanent framework or product fix. Verification includes independent, reordered, and parallel runs where relevant.
Frequently Asked Questions
What is test isolation in Cypress?
With end-to-end test isolation enabled, Cypress clears the page, cookies, local storage, and session storage before each test. It also resets aliases, intercepts, spies, stubs, clocks, and viewport changes so each test establishes its own prerequisites.
Is testIsolation true by default in Cypress?
Yes, test isolation is enabled by default for Cypress end-to-end tests. You can override it at an end-to-end describe block, but component testing always resets its browser context and does not support that configuration.
Why does a Cypress test pass alone but fail in a suite?
The test may depend on browser storage, server data, a shared account, a cached response, or an external resource changed by an earlier test. Run a minimal polluter-victim pair and vary one suspected channel at a time to prove the cause.
Does cy.session() disable test isolation?
No. cy.session() caches and restores cookies, local storage, and session storage while respecting the configured isolation behavior. With isolation enabled, call cy.visit() after restoring the session because the page may be blank.
Does Cypress clear intercepts between tests?
Yes, Cypress clears cy.intercept() routes and their aliases before every test. Register each required intercept in the test or in beforeEach before the request is triggered.
How do you debug Cypress tests in CI?
Preserve screenshots, video when enabled, browser and Cypress configuration, console and server logs, network metadata, shard order, retry attempt, and test-data identifiers. Reproduce the same command and environment, then minimize the failure before editing the test.
Should Cypress tests share data to run faster?
Mutable shared data usually creates order and parallel-execution failures. Prefer API-created, run-scoped data and use cy.session() for validated authentication reuse, which improves speed without coupling business records across tests.
Related Guides
- Cypress Scenario-Based Interview Questions and Answers (2026)
- Flaky Test Debugging Interview Questions (2026)
- Test Architect Selenium Grid Debugging Interview Questions (2026)
- API Test Engineer Interview Questions and Answers (2026)
- Cypress Component Testing Interview Questions for React (2026)
- Cypress Network Interception Interview Questions for Testers (2026)