当 运行 使用测试框架时,实际的云函数单元测试 { firebase-functions-test } 运行 在哪里?

Where does the actual cloud function unit test { firebase-functions-test } run when ran using a test framework?

我想知道,当 运行 使用测试 运行ner 时,云功能单元测试 运行 在哪里(比如 mocha开玩笑)?

npm run test

仅供参考,我不在任何 firebase 模拟器中 运行ning

当我 运行 使用 mocha 时,它能够创建写入 firestore(我确信 jest 会做同样的事情),但是我在日志中看不到函数名称,这意味着,函数 运行 在本地测试 运行ner 并写信给 firestore db.

这是否意味着无法使用测试 运行ner 从 firebase 后端调用 https 可调用云函数? 我已经尝试了两种方法:直接调用函数并使用 firebase-functions-test 库提供的 wrap() 方法进行包装。两次函数 运行 在本地。

直接调用:

.....
.....
.....
funcName.run({foo:"bar"}, { auth: { uid: "ABC" } });
.....
.....
.....

使用换行:

.....
.....
.....
const projectConfig = {
  projectId: 'my-project',
  databaseURL: 'https://my-project.firebaseio.com'
};
const test = require('firebase-functions-test')(projectConfig, './service-account-key.json');
wrapped = test.wrap(funcName);
expect(
        wrapped(
            { foo: "bar" },
            { auth: { uid: "ABC" } }
        )
).to.contain('foobar');
.....
.....
.....

Does that mean the https callable cloud functions can't be called from firebase backend using test runner?

firebase-functions-test 框架旨在 运行 一切都在本地进行,因此您可以在不依赖某些外部网络连接的情况下获得可预测且可靠的执行。它不会 运行 远程任何东西。

如果您想要 运行 已部署在某处的可调用函数,您可以编写代码以使用任何普通 HTTP 客户端库和 documentation 中提供的 onCall 协议信息直接调用它。