testing library

Fakes for testing code that uses package:firebase_database_dart: a scripted in-memory server (FakeDatabaseServer), a database connected to it (databaseWithFakeServer) and in-memory persistence (fakePersistence).

No stability promise beyond the package's contract tests.

final FakeDatabaseServer server = FakeDatabaseServer();
final FirebaseDatabase db = databaseWithFakeServer(
  app,
  server,
  persistence: fakePersistence(serverCache: <String, Object?>{'a': 1}),
);

Classes

FakeDatabaseServer
A server for tests that sits at the connection seam and answers only what the test tells it to.

Functions

databaseWithFakeServer(FirebaseApp app, FakeDatabaseServer server, {DatabasePersistence? persistence, DatabaseLogger? logger, Duration reconnectDelay = const Duration(seconds: 1)}) → FirebaseDatabase
A FirebaseDatabase of app connected to server instead of the network.
fakePersistence({Map<String, Object?> serverCache = const {}}) → DatabasePersistence
Persistence over an in-memory engine whose server cache starts as serverCache (paths to JSON values), as if a previous session had stored it. Durable for the life of the engine.