Running Firestore local e.g. for testing

前端 未结 7 922
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:36

Is there a way to run firestore locally (e.g. for testing purposes)?

What would the approach to write tests against the DB (except of using mocks)

相关标签:
7条回答
  • 2021-02-02 08:29

    Firestore can be setup in local using gcloud.

    Start the firestore emulator by running gcloud beta emulators firestore start --host-port=localhost:8081 and if it started successfully you will be seeing Dev App Server is now running

    In case if you are using @google-cloud/firestore then create the Firestore instance in this way

    // Firestore instance only for test env
    const { Firestore } = require('@google-cloud/firestore')
    const instance = new Firestore({ projectId; 'Your project id', host: 'localhost', 'port': 8081})
    
    0 讨论(0)
提交回复
热议问题