fake_cloud_firestore
4.5.0, released 4 weeks ago by wafrat.com
Fake implementation of Cloud Firestore for unit testing.
What it does
Provides a mock version of Cloud Firestore that keeps data in memory. Enables testing of apps using Cloud Firestore without needing a live backend connection or emulator.
AI-written summary of version 4.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to write unit or widget tests for apps that use Cloud Firestore.
- You need an in-memory database to quickly test queries, snapshots, and document updates.
Skip it when
- You are running integration tests that require actual backend connectivity or Firebase Emulators.
- You need to test features of Cloud Firestore that are not yet implemented by the fake library.
Strengths
- Runs entirely in memory for fast unit testing.
- Supports complex queries, transactions, batch writes, and custom security rules.
Weaknesses
- Does not support all Cloud Firestore features (e.g., timestamps and durations in security rules are limited).
- Requires maintaining compatibility versions matching the `cloud_firestore` package.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 10
not documented
import 'package:fake_cloud_firestore/fake_cloud_firestore.dart';
void main() async {
final instance = FakeFirebaseFirestore();
await instance.collection('users').add({
'username': 'Bob',
});
final snapshot = await instance.collection('users').get();
print(snapshot.docs.length); // 1
}Alternatives
Packages that do the same job and could replace fake_cloud_firestore.
- firebase_storage_mocks
Mocks for Firebase Storage to write unit tests.
82Compare - firebase_database_mocks
Mock library to write unit tests for Firebase Realtime Database.
77Compare - mockito
A mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing.
87Compare - mocktail
Dart mock library with null safety support and no manual mocks or code generation.
84Compare
Works with
Packages commonly used together with fake_cloud_firestore: ones it builds on, ones built on it, and its own family.
- clockfake_cloud_firestore depends on itA fakeable wrapper for dart:core clock APIs.
- plugin_platform_interfacefake_cloud_firestore depends on itReusable base class for platform interfaces of Flutter federated plugins.
- equatablefake_cloud_firestore depends on itProvides value‑based equality for Dart objects without manual == and hashCode.
- rxdartfake_cloud_firestore depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.
- cloud_firestorefake_cloud_firestore depends on itFlutter plugin for Cloud Firestore noSQL database with live synchronization.
- mock_exceptionsfake_cloud_firestore depends on itAllows throwing exceptions on specified method calls in fakes
- rxfake_cloud_firestore depends on itReactive Extensions library for Dart offering observable streams and async operators.
- firebase_auth_mocksSame familyMocks for Firebase Auth to enable unit testing of authentication flows.