dumbmatter / fakeIndexedDB

A pure JS in-memory implementation of the IndexedDB API
Apache License 2.0
562 stars 69 forks source link

Serializing (and restoring) the state of Fake IDB #91

Open joshdifabio opened 10 months ago

joshdifabio commented 10 months ago

I have the following use case for some automated tests:

  1. Run a JS application which reads/writes various data from/to Fake IDB
  2. Serialize the complete state of Fake IDB (e.g. to JSON)
  3. In a new context, rehydrate Fake IDB using the previous serialized state
  4. Run a JS application which reads/writes various data from/to Fake IDB, leveraging the state captured in step 2

Is there an easy way to achieve this with Fake IDB, or do I need to manually read/write all of the databases and objects using the regular IDB APIs?

dumbmatter commented 10 months ago

Right now there is no easy way to do this, you'd have to use the IndexedDB APIs. This would be a good feature to add in the future though.

tylerweitzman commented 1 month ago

I needed this use case too. I have created it in node-indexeddb