Running Firestore local e.g. for testing

前端 未结 7 1022
盖世英雄少女心
盖世英雄少女心 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:18

    Now you have an option to work with local firestore emulator by setting local host:

    var db = firebaseApp.firestore();
    if (location.hostname === "localhost") {
      db.settings({
        host: "localhost:8080",
        ssl: false
      });
    }
    

    https://firebase.google.com/docs/emulator-suite/connect_and_prototype#instrument_your_app_to_talk_to_the_emulators

提交回复
热议问题