firestore_mock 0.0.6

  • Readme
  • Changelog
  • Installing
  • 41

firestore_mock #

Google Cloud Firestore Test Helpers

Getting Started #

Create Firestore Mock #

MockFirestore mockFirestore = MockFirestore({
     "articles": {
         "document_id_1": {
           "title": "Flutter is Awesome",
           "author": "uid",
           "views": 123,
         },
         "document_id_2": {
           "title": "Kotlin is better than Dart",
           "author": "uid_2",
           "views": 999,
         }
   }
});

What is implemented (stubbed)? #

  • Add new document to collection
  • Get documents from collection
  • Get document by ID from collection
  • Query - where, limit, orderBy

Note: Methods (API) that return stream are not stubbed yet.

Example usage #

You can use public cloud_firestore package API.

final articles = mockFirestore.collection('articles').getDocuments();

print(articles.documents.length); // 3
print(articles.documents[0].documentID); // document_id_1
print(articles.documents[0].data['title']); // Flutter is Awesome

[0.0.6] 2019/09/26

  • Basic implementation of DocumentReference.snapshots()

[0.0.5] 2019/06/19

  • Updated cloud_firestore dependency to version 0.11.0+2
  • Added support for reading from subcollections

[0.0.4] - 2019/06/17

  • Empty implementation of DocumentReference.delete()
  • Basic implementation of DocumentReference.updateData(Map)

[0.0.3] - 2019/06/13

  • Basic mock implementation for Query.snapshots()

[0.0.2] - 2019/05/03

  • Query.limit, Query.orderBy

[0.0.1] - 2019/04/30

  • Get document from collection
  • Add document to collection
  • Query.where(...) - not working on nested fields yet

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  firestore_mock: ^0.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:firestore_mock/firestore_mock.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
3
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
41
Learn more about scoring.

We analyzed this package on Oct 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (cloud_firestore).

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and firestore_mock.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cloud_firestore ^0.11.0+2 0.11.0+2 0.12.9+5
flutter 0.0.0
kt_dart ^0.6.1 0.6.2
meta ^1.1.6 1.1.7
mockito ^4.0.0 4.1.1
Transitive dependencies
async 2.4.0
boolean_selector 1.0.5
charcode 1.1.2
collection 1.14.11 1.14.12
firebase_core 0.4.0+9
matcher 0.12.5
path 1.6.4
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
stack_trace 1.9.3
stream_channel 2.0.0
string_scanner 1.0.5
term_glyph 1.1.0
test_api 0.2.8
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
test ^1.5.3