猿问

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

尝试测试我的 Firebase 云功能。我已按照文档进行操作,但在运行测试时出现以下错误。我尝试生成不同的密钥,我通过 Firebase 进入服务密钥窗口,所以它是正确的项目。运行测试时出现错误:npm test


Error: 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();


慕容708150
浏览 117回答 1
1回答

慕斯709654

它说无效的键“_fieldProto”,如果你看看这个字典实际包含的内容:"fieldsProto":{"foo":{"stringValue":"bar"}}我认为您只需要删除传递给包装函数的参数即可。const wrapped = test.wrap(myFunctions.testFunction);wrapped();&nbsp;test.cleanup();
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答