如何在Firebase emulator中存根外部服务?

如何在Firebase emulator中存根外部服务?,firebase,google-cloud-firestore,mocha.js,firebase-security,sinon,Firebase,Google Cloud Firestore,Mocha.js,Firebase Security,Sinon,我有一个firestore触发器函数,它基于slug属性创建DNS记录。我有一些单元测试,我在那里存根@googlecloud/dns模块,所以没有外部HTTP请求。但是,我也有一些集成测试。它们正在攻击本地firebase emulator(localhost:8080) 例如,在测试firestore规则时,我只需调用db.collection('path').add(model),这将触发emulator进程内的可调用函数 测试通过以下命令运行:firebase模拟器:exec'mocha

我有一个firestore触发器函数,它基于slug属性创建DNS记录。我有一些单元测试,我在那里存根
@googlecloud/dns
模块,所以没有外部HTTP请求。但是,我也有一些集成测试。它们正在攻击本地firebase emulator(localhost:8080)

例如,在测试firestore规则时,我只需调用
db.collection('path').add(model)
,这将触发emulator进程内的可调用函数

测试通过以下命令运行:
firebase模拟器:exec'mocha--config spec/.mocharc.yml
首先,它初始化模拟器,然后运行测试。据我所知,这些是不同的过程。因此,在mocha流程中,我能够使用模块进行存根、模拟。另一方面,在emulator进程内,函数、模块和依赖项已按原样加载。因此,当我在mocha测试套件中运行测试firestore规则的测试脚本时:

await assertSucceeds(db.doc('stores').set(store));
它实际上运行处理程序并将请求发送到google云DNS。有人遇到过这样的问题吗?提前谢谢