All Projects → GitbookIO → expect-firestore

GitbookIO / expect-firestore

Licence: other
API client and Jasmine matchers for the Firestore Rules API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to expect-firestore

likecoin-tx-poll
Firestore based service of polling eth status and resending tx
Stars: ✭ 13 (-40.91%)
Mutual labels:  firestore
gatsby-source-firestore
Gatsby source plugin for building websites using the Firestore as a data source.
Stars: ✭ 30 (+36.36%)
Mutual labels:  firestore
SwiftUIRealtimeShoppingCart
SwiftUI Collaborative Shopping Cart with Firestore Database
Stars: ✭ 34 (+54.55%)
Mutual labels:  firestore
FirestoreMovies
Simple Movie application showcasing use of Firestore document based database.
Stars: ✭ 28 (+27.27%)
Mutual labels:  firestore
voting system app
E-voting system based on blockchain technology, with ethereum, flutter/dart
Stars: ✭ 59 (+168.18%)
Mutual labels:  firestore
firebase-tutorial
This repo contains the code for the youtube playlist about React.js and Firestore. Covered are setting up Firesore in a React-App and much more.
Stars: ✭ 33 (+50%)
Mutual labels:  firestore
loopback-connector-firestore
Firebase Firestore connector for the LoopBack framework.
Stars: ✭ 32 (+45.45%)
Mutual labels:  firestore
gatsby-firebase-starter
🔥 Starter Project / Boilerplate for Authentication and creating Dynamic pages from collections with Firebase and Gatsby.js.
Stars: ✭ 61 (+177.27%)
Mutual labels:  firestore
firestore-seed
Seed data library for Cloud Firestore.
Stars: ✭ 22 (+0%)
Mutual labels:  firestore
fire-fuse
Powerful typing utilities for firestore.
Stars: ✭ 18 (-18.18%)
Mutual labels:  firestore
firestore-jest-mock
Jest Helper library for mocking Cloud Firestore
Stars: ✭ 128 (+481.82%)
Mutual labels:  firestore
firestore-social-backend
The backend code of firestore client for React Social Network
Stars: ✭ 36 (+63.64%)
Mutual labels:  firestore
Flutter-firestore-auth
Flutter mobile app with firestore authentication including Email and Social auth.
Stars: ✭ 95 (+331.82%)
Mutual labels:  firestore
open-feedback
Open Feedback is an opened SaaS platform destined to organisers to gather feedback from users. OpenFeedback
Stars: ✭ 67 (+204.55%)
Mutual labels:  firestore
restaurant
🍕 Simple Pizza Restaurant POS
Stars: ✭ 29 (+31.82%)
Mutual labels:  firestore
ionic4-ngrx-firebase
A basic application for Ionic 4 with firebase & ngrx actions, reducers and effects
Stars: ✭ 17 (-22.73%)
Mutual labels:  firestore
universal-translator
Demo app using Firebase and Google Cloud products to implement a "universal translator"
Stars: ✭ 37 (+68.18%)
Mutual labels:  firestore
webneko-blog
✍️ Technical Blog written by @jiyuujin
Stars: ✭ 14 (-36.36%)
Mutual labels:  firestore
Facebook-Messenger
This is a Facebook Messenger clone.You can comminicate to other at realtime.Used ReactJS, Material UI, Firebase, Firestore Database
Stars: ✭ 18 (-18.18%)
Mutual labels:  firestore
oneroof
Learn about firebase crud operation authentication, animation
Stars: ✭ 15 (-31.82%)
Mutual labels:  firestore

expect-firestore

Build Status

Node module to easily unit tests Firestore rules. It abstract the Firestore Rules testing API to easily mock a dataset.

Install

$ yarn add expect-firestore

Usage

import assert from 'assert';
import * as firestore from 'expect-firestore';

const database = new firestore.Database({
    // Credentials from firebase console
    credential: { project_id: '...', ... },
    // Fake data to test assertions against
    data: {
        // See src/__tests__/fixtures/db.json for an example
        users: [
            {
                key: 'userA',
                fields: {
                    name: 'John Doe'
                },
                collections: {
                    favorites: [
                        ...
                    ]
                }
            },
            ...
        ]
    },
    // Firestore rules
    rules: ''
});

// Authorize the client database
await database.authorize();

// Test a get
const result = await database.canGet({ uid: 'some_user' }, 'users/userA');
firestore.assert(result);

API

Global

  • new firestore.Database({ data, credentials, rules }): Create a database instance to test rules

    const database = new firestore.Database({
        credentials: require('credential.json')
    });
  • firestore.assert(test: TestResult): Throw a human readable error if test failed, otherwise do nothing

    const result = await database.canGet({}, 'users/userA');
    firestore.assert(result);

firestore.Database

  • database.authorize(): Promise<void>: Prepare the testing environment, it must be called at least once.

Run get, set, update and commit tests using:

  • database.canGet(auth: FirestoreAuth, document: string): Promise<TestResult>
  • database.cannotGet(auth: FirestoreAuth, document: string): Promise<TestResult>
  • database.canSet(auth: FirestoreAuth, document: string, value: any): Promise<TestResult>
  • database.cannotSet(auth: FirestoreAuth, document: string, value: any): Promise<TestResult>
  • database.canUpdate(auth: FirestoreAuth, document: string, values: Object): Promise<TestResult>
  • database.cannotUpdate(auth: FirestoreAuth, document: string, values: Object): Promise<TestResult>
  • database.canCommit(auth: FirestoreAuth, batch: BatchOperation[]): Promise<TestResult>
  • database.cannotCommit(auth: FirestoreAuth, batch: firestore.BatchOperation[]): Promise<TestResult>

Control test testing environment using:

  • database.setData(data: FirestoreCollections): Update the dataset
  • database.setRules(rules: string): Update the rules being tested
  • database.setRulesFromFile(file: string): Read the rules from a file

firestore.Batch

  • firestore.Batch.set(document: string, value: any): BatchOperation
  • firestore.Batch.update(document: string, values: Object): BatchOperation
  • firestore.Batch.delete(document: string): BatchOperation
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].