Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

Cypress Test Isolation: Why It Matters and How to Use It

Cypress test isolation starts end-to-end tests in a clean browser context. Learn what it resets, how cy.session() preserves authentication, and when a scoped exception makes sense.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cypress end-to-end test isolation is enabled by default. It gives each test a clean browser context, so the test can pass on its own as well as after other tests. Keep isolation enabled for most tests; use cy.session() to reuse login state, and disable isolation only for a deliberately scoped suite whose tests you have verified independently.

What Cypress test isolation resets

With end-to-end testIsolation: true, Cypress visits about:blank before each test and clears cookies, localStorage, and sessionStorage across all domains. It also resets Cypress test state, including aliases, clock mocks, intercepts, spies, stubs, and viewport changes. See Cypress’s test isolation documentation for the current behavior.

As an Amazon Associate I earn from qualifying purchases.

This is not a wipe of every browser storage mechanism. IndexedDB and other storage mechanisms are not cleared by test isolation. If your application relies on them, add explicit cleanup or deterministic setup so a test does not inherit data from earlier work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why independent tests matter

A test that passes only after another test has run has an implicit dependency: its result depends on execution order or leftover state. Such tests are harder to run selectively, reproduce, and debug. Cypress’s guidance is that tests should pass both independently and consecutively with other tests.

Isolation does not make a test reliable by itself. Each test still needs to establish the application state it requires and avoid depending on a previous test’s DOM, login, storage, or mocked behavior.

How to use the default isolation setting

Keep end-to-end isolation enabled by default

For most end-to-end suites, leave testIsolation enabled. Cypress enables it by default, and each test starts with a clean browser context. Write setup in the test or in reusable commands and hooks so the test can establish its own starting conditions.

Reuse authentication with cy.session()

When several tests need the same authenticated state, cy.session() can capture and restore cookies and local or session storage created during session setup. Put the session logic in a reusable login command or wrapper instead of repeating it across specs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

With isolation enabled, the page is cleared when the session is set up or restored. Visit the application after calling the session so the test has a page to work with. Session data is cleared before the session’s setup function regardless of the isolation setting.

Disable isolation only for a specific end-to-end suite when needed

If a particular suite must preserve the page or browser context between tests, Cypress allows testIsolation to be overridden at the describe/context level. Scoping the override limits its effect; disabling isolation broadly makes it easier for unrelated tests to become order-dependent.

With testIsolation: false, Cypress does not alter the browser context before each test, so page state, cookies, and storage may remain. Before relying on this, run each affected test by itself with .only() and confirm it still passes. Preserved state can reduce repeated setup, but it introduces a risk that one test silently prepares the next.

Isolation, session caching, and component tests compared

Case Page and DOM Cookies and web storage Setup and dependency trade-off
End-to-end, testIsolation: true Visits about:blank before each test Clears cookies, localStorage, and sessionStorage across domains Tests establish their own state; use cy.session() to restore login data, then visit the app
End-to-end, testIsolation: false Does not reset the browser context before each test Cookies and storage may persist May reduce repeated setup, but tests can become order-dependent; verify each test alone
End-to-end with cy.session() With isolation enabled, the page is cleared during session setup/restoration Session restores cookies and local/session storage Reusable authentication setup; visit the application after restoring the session
Component testing Cypress unmounts the rendered component before each test Clears cookies, localStorage, and sessionStorage The configurable end-to-end testIsolation setting is not available for component tests

IndexedDB and other browser storage are not cleared by the isolation behavior described above. Do not assume that a clean page and cleared web storage also mean every form of persisted browser data has been erased.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Migration note for Cypress 12

Cypress’s migration guide identifies Cypress 12 as the release that enforced a clean browser context for tests. If a suite was written to rely on the application page carrying over between tests, review that assumption: tests may need to revisit the app and rebuild browser state. The migration guidance describes the setting as testIsolation: true or false; treat this as Cypress 12 migration context, not a claim about every historical configuration detail. See the Cypress migration guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting isolation-related failures

  • A test fails alone but passes after another test: it likely relies on prior state. Add the needed setup to the test or a reusable hook/command instead of relying on execution order.
  • A login disappears before the test: with isolation enabled, page state is cleared. Use cy.session() for reusable authentication data and call cy.visit() afterward.
  • Data remains even though isolation is on: isolation does not clear IndexedDB or other storage mechanisms. Clean those explicitly or make setup deterministic.
  • A test breaks after setting testIsolation: false: state may be leaking between tests. Scope the override to the relevant suite and verify each test with .only().
  • A component test appears to ignore testIsolation: Cypress uses fixed reset behavior for component testing; the configurable end-to-end option does not apply there.

Performance and reliability trade-offs

Cypress says disabling isolation may improve end-to-end performance, but does not provide a quantified gain in the cited guidance. Treat any speed benefit as workload-dependent rather than guaranteed. Compare the cost of repeated setup with the debugging and maintenance cost of hidden state dependencies; preserve isolation unless a scoped exception is necessary and independently verified.

Or skip the browser setup

If you need a website screenshot rather than a Cypress test, ScreenshotNeo is a screenshot API and MCP server. Its one-call API request accepts a URL and returns an image or PDF. For example, using cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the ScreenshotNeo API documentation for parameters. It accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.