You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Another solution would be to add some non-standard functions to indexedDB that would be useful in testing. Like indexedDB.reset() could delete all the object stores. And other stuff like #50 and #51.
That works, but I agree, we should have an easier way of doing this! I also had a type error with the 'auto' import in my Angular Jasmine project. It was complaining that indexedDB can't be assigned and that it is a getter on window. I managed to get passed that typeerror by doing Object.defineProperty(window, 'indexedDB', { value: indexedDb, writable: true }); BEFORE the import from auto happens. although in retrospect you may or may not need the writable true part, and maybe this solution should also be included in the auto logic as a part of this library
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:
So far I've tracked this back to
3.0.3
which is the version we're currently using.The text was updated successfully, but these errors were encountered: