What this thread does
Do first: keep testIsolation: true and add an awaited beforeEach reset for every IndexedDB database owned by the application.
Short answer
As of November 2026, Cypress 16.3.0, released November 10, clears cookies and web storage between isolated tests, but does not clear IndexedDB. The January 19, 2018 report by andreiashu remains relevant as a storage boundary.
Choose / don't choose
- Delete databases: choose when the database must be deleted; use an explicit application database-name allowlist (deletion).
- Clear stores through an app hook: choose when retaining the schema is intentional.
IDBObjectStore.clear()removes records and index entries (clear, transaction contract).
Not for: changing browser test runners; see migrate-e2e-test-suite-slice-by-slice.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
testIsolation | true clears page by visiting about:blank; IndexedDB remains outside automatic cleanup | Current Cypress E2E docs | isolation |
beforeEach | Reset before fixture seeding in every test, including the first | Current Cypress docs | isolation |
indexedDB.deleteDatabase(name) | Each exact application-owned name, on its origin; returns an asynchronous request | IndexedDB | delete |
onsuccess, onerror, onblocked | Resolve only on success; reject errors and blocked deletion under this strict reset policy | Request lifecycle; policy choice | algorithm, request |
onversionchange / close() | Call IDBDatabase.close() from inside the versionchange event handler in the second tab | IndexedDB | event handling |
cy.window().then(...) | If the return value is a Promise, Cypress will wait for it to resolve | Current Cypress chain | then |
Order of operations
1. Visit the app origin with database initialization paused by an application-owned test hook; if already started, stop producers and close connections first. The hook name is application-specific. 2. From cy.window().then(...), return and await a Promise for every allowlisted deletion. The method returns an IDBOpenDBRequest object immediately (then, delete). Strict single-name adapter:
return new Cypress.Promise((resolve, reject) => {
const request = win.indexedDB.deleteDatabase(name);
request.onsuccess = resolve;
request.onerror = () => reject(request.error);
request.onblocked = () => reject(new Error('IndexedDB deletion blocked'));
});
3. Seed fixtures only after deletion succeeds, then resume startup. The adapter's error string is application-defined. Close connections in other tabs/workers too: deletion waits for every connection (specification). 4. Run two tests writing conflicting records; the second should start with only its fixture. Reverse their order. Reset must not depend on the previous test reaching teardown.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
blocked (event) | Open connections prevent deletion | Close owners; fail reset rather than seed into stale storage | algorithm, versionchange |
| Persisted records in next test (symptom) | IndexedDB is outside isolation | Explicit reset at the app origin before seeding | isolation, andreiashu report |
Missing
- Actual names, origins and connection owners are application-specific. Cypress's illustrative reset resolves on blocked/error outcomes; that example does not guarantee an empty database. This card uses stricter failure handling.
- IndexedDB is outside session snapshots:
cy.session()caches and restores cookies, localStorage and sessionStorage only (isolation; checked 2026-11-24).
Checked
2026-11-12; Cypress changelog/isolation/then, dated issue, IndexedDB draft dated October 30, 2026, and browser deletion/clear/versionchange references read. No Cypress commands executed.
Started from a post by @Cypress, packaged by the editor. Original post