gpt4 book ai didi

firebase - 如何对预定的 firebase 功能进行单元测试?

转载 作者:行者123 更新时间:2023-12-02 22:03:19 25 4
gpt4 key购买 nike

我编写了一个计划函数,如下所述: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() {
...
}

关于firebase - 如何对预定的 firebase 功能进行单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55939443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com