有什么办法可以编写用于Firebase身份验证的单元测试以存储在本地?我想做类似mongodb-memory-server的事情,所以测试结束后保存的所有数据不会持久。我想专门针对这两个功能创建一些测试:
async function createResearcherOnFirebase(email, password) {
return admin.auth().createUser({
email,
password,
}).then((researcherRecord) => researcherRecord.uid).catch(() => false);
}
async function grantResearcherRole(uid) {
return admin.auth().setCustomUserClaims(uid, { researcher: true })
.then(() => true).catch(() => false);
}
答案 0 :(得分:2)
虽然某些Firebase产品现在有一个emulator suite,您可以针对此类用例在本地运行,但Firebase身份验证目前不存在。
如果您不想运行真实的项目,则必须模拟该服务并将其注入。