为了账号安全,请及时绑定邮箱和手机立即绑定

Firebase 功能测试初始化​​失败

Firebase 功能测试初始化​​失败

慕容708150 2023-04-27 10:21:08
尝试测试我的 Firebase 云功能。我已按照文档进行操作,但在运行测试时出现以下错误。我尝试生成不同的密钥,我通过 Firebase 进入服务密钥窗口,所以它是正确的项目。运行测试时出现错误:npm testError: Options object {"_fieldsProto":{"foo":{"stringValue":"bar"}},"_ref":{"_firestore":{"_settings":{"credentials":{"private_key":"KEY","client_email":"project@appspot.gserviceaccount.com"},"projectId":"project","firebaseVersion":"8.13.0","libName":"gccl","libVersion":"3.8.6 fire/8.13.0"},"_settingsFrozen":false,"_serializer":{"allowUndefined":false},"_projectId":"project","registeredListenersCount":0,"_lastSuccessfulRequest":0,"_backoffSettings":{"initialDelayMs":100,"maxDelayMs":60000,"backoffFactor":1.3},"_preferTransactions":false,"_clientPool":{"concurrentOperationLimit":100,"maxIdleClients":1,"activeClients":{},"terminated":false,"terminateDeferred":{"promise":{}}}},"_path":{"segments":["document","path"],"projectId":"project","databaseId":"(default)"},"_converter":{}},"_serializer":{"allowUndefined":false},"_readTime":{"_seconds":1602169684,"_nanoseconds":285000000},"_createTime":{"_seconds":1602169684,"_nanoseconds":285000000},"_updateTime":{"_seconds":1602169684,"_nanoseconds":285000000}} has invalid key "_fieldsProto"    at /home//Desktop/Work/test-app/app/functions/node_modules/firebase-functions-test/lib/main.js:99:19    at Array.forEach (<anonymous>)    at _checkOptionValidity (/home//Desktop/Work/test-app/app/functions/node_modules/firebase-functions-test/lib/main.js:97:26)    at scheduledWrapped (/home//Desktop/Work/test-app/app/functions/node_modules/firebase-functions-test/lib/main.js:36:13)    at Object.<anonymous> (/home//Desktop/Work/test-app/app/functions/index.test.js:98:1)const test = require('firebase-functions-test')({     databaseURL: "####",     storageBucket: "####",     projectId: "#####",   }, './key.json');  const myFunctions = require('./index.js'); const wrapped = test.wrap(myFunctions.testFunction);const snap = test.firestore.makeDocumentSnapshot({foo: 'bar'}, 'document/path'); wrapped(snap); test.cleanup();
查看完整描述

1 回答

?
慕斯709654

TA贡献1840条经验 获得超5个赞

它说无效的键“_fieldProto”,如果你看看这个字典实际包含的内容:


"fieldsProto":{"foo":{"stringValue":"bar"}}

我认为您只需要删除传递给包装函数的参数即可。


const wrapped = test.wrap(myFunctions.testFunction);

wrapped(); 

test.cleanup();


查看完整回答
反对 回复 2023-04-27
  • 1 回答
  • 0 关注
  • 116 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信