Javascript Firestore SDK无法模拟DocumentSnapshot

Javascript Firestore SDK无法模拟DocumentSnapshot,javascript,firebase,unit-testing,google-cloud-firestore,mocha.js,Javascript,Firebase,Unit Testing,Google Cloud Firestore,Mocha.js,因此,我试图为firestore触发器创建一个单元测试,由onCreate事件触发。firebase文档说这样做: 我非常仔细地复制文档: const snapshot = test.firestore.makeDocumentSnapshot( {owner: 'testUserA', text: 'response from test user a'}, 'users/testUserA/questions/testQuestion/responses/testRespon

因此,我试图为firestore触发器创建一个单元测试,由
onCreate
事件触发。firebase文档说这样做:

我非常仔细地复制文档:

const snapshot = test.firestore.makeDocumentSnapshot(
    {owner: 'testUserA', text: 'response from test user a'}, 
    'users/testUserA/questions/testQuestion/responses/testResponse'
);
这一行给出了错误:

未经处理的PromisejectionWarning:SyntaxError:JSON中位于位置0的意外标记u

起初我认为它可能与
refPath
有关,因为它以u开头,但更改后,错误是相同的,因此我假设它与第一个参数有关,它看起来像是正确的json,但显然不是。我有点被难住了


有什么想法吗?谢谢

在使用
test.firestore.makeDocumentSnapshot()
之前,您是否在任何其他测试用例中使用了
test.cleanup()
?如果有,请删除它们并再次运行测试

您可以将问题发布到项目GitHub。