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
The snapshot utility would memorize the state of the database (its entities) at a call time, and allow to restore to that memorized state at any further point of time (i.e. before each test).
Usage
import{factory,primaryKey,snapshot}from'@mswjs/data'constdb=factory({user: {id: primaryKey(String),firstName: String}})db.user.create({firstName: 'John'})db.user.create({firstName: 'Kate'})// Takes a snapshot of the database// in this point of time.constrestore=snapshot(db)// Perform some other actions.db.user.create({firstName: 'Joe'})// Restores the database to the taken snapshot.// Will result in a database with 2 users:// "John" and "Kate".restore()
Restoring a database is effectively reset it to a given initial state. This may mean that #49 is a prerequisite for this task, as persistency also uses a restoration logic that hydrates a database instance from the sessionStorage.
Expected behavior
The
snapshot
utility would memorize the state of the database (its entities) at a call time, and allow to restore to that memorized state at any further point of time (i.e. before each test).Usage
GitHub
The text was updated successfully, but these errors were encountered: