MockDBProviderclass

new MockDBProvider<I, T>()
Return
MockDBProvider<I, T>
In-memory database provider that records every operation to its calls log, for testing.
PropertyType
.callsMockDBCall[]
The log of operations performed through this provider, in the order they happened. Defaults to [] readonly

In-memory database provider that records every operation to its calls log, for testing.

  • Extends MemoryDBProvider, so it stores data normally, then appends a MockDBCall entry (including the result) for each call.
  • Assert against calls in tests to check which operations ran and with what arguments.

Examples

const provider = new MockDBProvider();
 await provider.addItem(users, { name: "Dave" });
 provider.calls; // [{ type: "addItem", collection: "users", data: { name: "Dave" }, result: 123 }]