【发布时间】:2015-11-04 22:06:45
【问题描述】:
谁能帮我做这个测试?如何为 nodejs HAPI 模块编写的这个 API 编写单元测试。对于测试,我必须使用 Lab 模块。 这是 route.js 文件:
path: '/makes',
method: 'GET',
config: {
handler: cars.getMakes
这是处理程序:
getMakes: function (request, reply) {
Make //this is a model of moongose in my DB
.find()
.sort('name')
.exec( function(err, result) {
if (err) {
request.log(['server', 'database', 'error'], 'An error occurred during the execution of the query');
}
return reply(result)
.code(200);
});
},
我自己写的,但我有这样的错误:
getaddrinfo ENOTFOUND undefined
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
【问题讨论】:
-
Stack Overflow 不是代码编写服务。
-
@GergoErdosi 我不需要写入服务,我已经编写了它,但是在 GetAddrInfoReqWrap.onlookup [as oncomplete] 的 errnoException (dns.js:44:10) 处出现错误 getaddrinfo ENOTFOUND undefined (dns.js:94:26)
标签: javascript node.js unit-testing hapijs