fakeIndexedDB icon indicating copy to clipboard operation
fakeIndexedDB copied to clipboard

Add observation for Dexie users

Open hyphenized opened this issue 1 year ago • 3 comments

When using Dexie.js, it caches the global indexedDB variable, so resetting the db state won't work as expected. An easy fix is to manually handle each constructor call to explicitly use a new instance of fakeIndexedDB or add a getter to override the value in your test setup like this:

Object.defineProperty(Dexie.dependencies, "indexedDB", {
  get: () => indexedDB,
})

So far I've tracked this back to 3.0.3 which is the version we're currently using.

hyphenized avatar Oct 13 '22 06:10 hyphenized