在本地运行Firestore供测试用 [英] Running Firestore local e.g. for testing

查看:118
本文介绍了在本地运行Firestore供测试用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在本地运行firestore(例如出于测试目的)?

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)

推荐答案

2020年更新:


现在还有一个< a href = https://firebase.google.com/docs/emulator-suite rel = nofollow noreferrer> Firebase模拟器套件。

本地仿真(至少出于测试Firestore规则的目的)被降级了在Firebase Summit 2018上使用 @ firestore / testing ,并记录在测试您的Cloud Firestore安全规则

Local emulation, at least for the purpose of testing Firestore rules, was demoed at Firebase Summit 2018 using @firestore/testing and documented under Test your Cloud Firestore Security Rules.

看起来像这样:

const firebase = require(`@firebase/testing`)
const app = firebase.initializeTestApp({
  projectId: 'my-project',
  auth: { uid: '123', email: 'name@domain.com' }
})

const attempt = app.firestore()
  .collection('colId').doc('docId').get()
firebase.assertFails(attempt)
firebase.assertSucceeds(attempt)

这似乎很早,因为发行说明中没有对此进行说明,但是我敢肯定它会随之而来。

It seems early-on, as it's not been noted in the release-notes, but I'm sure it's coming along.

这篇关于在本地运行Firestore供测试用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆