Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud firestore 我可以在Firebase Emulator云函数中保留全局状态吗?_Google Cloud Firestore_Google Cloud Functions_Firebase Tools - Fatal编程技术网

Google cloud firestore 我可以在Firebase Emulator云函数中保留全局状态吗?

Google cloud firestore 我可以在Firebase Emulator云函数中保留全局状态吗?,google-cloud-firestore,google-cloud-functions,firebase-tools,Google Cloud Firestore,Google Cloud Functions,Firebase Tools,我想在模拟器中运行调用多个云函数的测试,这些函数使用模拟的外部服务getstream.io。这意味着mock必须在函数调用过程中保持不变。这样的事情可能吗 let mock = new SomethingMock(); exports.resetMock = functions.https.onCall((data, context) => { mock = new SomethingMock(); }); exports.addActivity = functions.https

我想在模拟器中运行调用多个云函数的测试,这些函数使用模拟的外部服务getstream.io。这意味着mock必须在函数调用过程中保持不变。这样的事情可能吗

let mock = new SomethingMock();

exports.resetMock = functions.https.onCall((data, context) => {
  mock = new SomethingMock();
});

exports.addActivity = functions.https.onCall(async (data, context) => {
  await mock.addActivity(something);
});

exports.getActivities = functions.https.onCall((data, context) => {
  // assumes addActivity has been called a few times
  return mock.getActivities();
});
本页没有保证在生产中保持全局状态,但没有说明emulator:

firebase emulator既不能保证全局状态的保存。 答案是:

Firebase本地仿真器套件由单个服务仿真器组成,这些仿真器用于准确模拟Firebase服务的行为。这意味着您可以将应用程序直接连接到这些模拟器,以执行集成测试或QA,而无需接触生产数据。模拟firebase服务是为准确性而构建的,而不是性能或安全性,不适合在生产中使用


话虽如此,拥有一个不会像服务在生产中一样返回结果的仿真器并没有多大附加值。

尽管该文本暗示了这种情况,但它并没有直接确认这种特定行为是完全模仿的。你是emulator的开发者之一吗?如果确实没有办法保存全局状态,我可以绕过它启动一个external Node.js服务,但是如果有办法防止这种情况发生,那就太好了,即使有一些特殊的对象我可以为其分配属性或其他东西。不,我不是开发者。如果您想要firebase团队的直接回答,那么您应该打开一个github问题。看来这个问题被否决了。还不够清楚吗?还是因为文档暗示了什么,但我在寻找更明确的答案?任何关于如何改进我的贡献的建议都是非常受欢迎的。而且,这也是我还没有解决的问题。我正在考虑启动一个external Node.js服务器来模拟依赖关系,以解决这个问题。所以我也不能写一个我能接受的答案。