firebase - 如何对预定的 Firebase 功能进行单元测试?
问题描述
我已经编写了一个预定函数,如下所述:https ://firebase.google.com/docs/functions/schedule-functions
我现在如何测试这个功能?当我包装这个函数时(就像我对任何其他云函数一样),有一个错误说:“类型'TestFunction'上不存在属性'wrap'。”
const functionWrapper = test.wrap(function);
有没有其他方法可以测试这些功能?
解决方案
我发现的一种解决方法是将我的代码隔离在一个函数中,并从预定函数中调用该函数。我测试的时候,不是调用调度函数,而是直接调用隔离函数。
前任:
export const dailyJob = functions.pubsub
.schedule('0 0 * * *')
.onRun(async context => {
return isolatedFunction();
})
export function isolatedFunction() {
...
}
推荐阅读
- python-3.x - 从字节数组中拆分字符串
- javascript - 是否可以将 id/ 字符串传递给 onFocus 事件?
- node.js - 在nodejs中写一个json文件
- python - 如何从 django 中的多个模型中查询
- java - 如何在 Java 中为新文件自动提交 git
- c++ - 如何将 Boost DLL 放入 CMake 安装目录?
- excel-formula - 如何在GETPIVOTDATA中引用包含monthnameshort的单元格范围
- ssh - VS Code:通过 SSH 从 Windows 自动上传(部署)文件
- elasticsearch - 如何根据分片数计算 Elasticsearch 的分片数?
- python - python中基于response.status_code的循环函数