gpt4 book ai didi

unit-testing - 如何为服务器端 Meteor 代码编写单元测试?

转载 作者:行者123 更新时间:2023-12-04 12:46:22 24 4
gpt4 key购买 nike

我有一些服务器端代码——meteor 方法和简单的后端助手——我想测试它们。我已经阅读了使用 Meteor 进行的文档测试,但是我很难将文档与我的非常简单的用例联系起来。有人可以与我分享他们如何测试 meteor 方法或简单的后端 JS 函数吗?

例如,假设您在 some_methods.js 中有一些服务器方法

function someHelper() {
// does lots of cool stuff
};

Meteor.methods({
'user/update' (userProperties) {
// updating some user properties
someHelper();
}
})

最佳答案

我们为名为 RadGrad ( https://radgrad.org ) 的开源应用程序开发了单元和集成测试。

有关我们如何进行单元和集成测试的详细信息,请参阅:

https://www.radgrad.org/docs/developer-guide-testing.html

以下是单元(仅限服务器端)测试的示例:

https://github.com/radgrad/radgrad/blob/master/app/imports/api/career/CareerGoalCollection.test.js

这是集成(客户端 + 服务器)测试的示例:

https://github.com/radgrad/radgrad/blob/master/app/imports/api/career/CareerGoalCollection.methods.app-test.js

我们没有广泛的 UI 测试;为此,您需要使用 Selenium 之类的东西。 Meteor 中的 UI 测试与任何其他 Web 应用程序的 UI 测试没有什么不同。

关于unit-testing - 如何为服务器端 Meteor 代码编写单元测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37530335/

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