testDBProvider()function
testDBProvider(name: string, createProvider: () => DBProvider<string, Data> | PromiseLike<DBProvider<string, Data>>, { realtime = true, transactions = false, nestedTransactions = false }: TestDBProviderOptions = {}): void| Param | Type | |
|---|---|---|
name | string | Name for the provider used in the describe block. required |
createProvider | () => DBProvider<string, Data>PromiseLike<DBProvider<string, Data>> | Create (or return) the provider instance to test. required |
options | TestDBProviderOptions | Capability flags for the provider under test. Defaults to {} |
.realtime | boolean | Whether the provider supports realtime sequences — when false, sequences are asserted to throw UnsupportedError (including inside transact()); when true combined with transactions, sequences inside a transaction are asserted to observe the transaction and end with it. Defaults to true readonly |
.transactions | boolean | Whether the provider supports transact() — when false, it is asserted to throw UnsupportedError. Defaults to false readonly |
.nestedTransactions | boolean | Whether transact() can be nested, committing the inner transaction into the outer — when false, nested calls are asserted to throw UnsupportedError. Defaults to false readonly |
Register the universal DBProvider contract test suite against a provider, so every backend proves the same behaviour.
- Calls
createProvider()fresh for every test and wipesBASICS_COLLECTIONandPEOPLE_COLLECTIONfirst, so persistent backends (e.g. an emulator) start each test clean. - Declare the provider's capabilities via options — unsupported capabilities are asserted to throw
UnsupportedErrorrather than skipped.
Examples
testDBProvider("MemoryDBProvider", () => new MemoryDBProvider<string>());