Firestore SDK无法模拟DocumentSnapshot

问题描述 投票:0回答:1

因此,我试图为由onCreate事件触发的Firestore触发器创建单元测试。 Firebase文档说是这样做的:Firebase Unit Testing Background Functions

我非常仔细地复制了文档:

const snapshot = test.firestore.makeDocumentSnapshot(
    {owner: 'testUserA', text: 'response from test user a'}, 
    'users/testUserA/questions/testQuestion/responses/testResponse'
);

此行显示错误:

[UnhandledPromiseRejectionWarning:语法错误:JSON在位置0处出现意外的令牌u

起初我认为它可能与refPath有关,因为它以u开头,但是在更改它之后,错误是相同的,因此我认为它与第一个参数有关,这似乎是正确的json,但显然不是。我有点受困。

有什么想法吗?谢谢!

javascript firebase unit-testing google-cloud-firestore mocha
1个回答
0
投票

使用test.cleanup()之前,您是否还有其他测试用例?如果有,请删除它们,然后再次运行测试

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.