【发布时间】:2012-08-14 16:59:34
【问题描述】:
我在我的应用程序中使用 nimble.js 并使用 mocha + chai 进行测试,但昨天我发现它们可能存在冲突。
基本上,当我在浏览器中执行特定的 http 请求时,我会得到
Unauthorized.
这是正确的回答。
但是使用 node 的 http 模块使用相同的 url 做一个 http 请求,我得到了
not found
这让我很困惑。
我知道 http 请求得到了正确的 url,因为我在服务器控制台中看到了它,甚至可以将它复制粘贴到我的浏览器中。
另外,我将代码追溯到 nimble.parallel 函数。
我有这样的事情:
// var _ = require('nimble');
_.parallel(
[
fetch_account(options)
, fetch_invoice(options)
, fetch_site(options)
, fetch_account_stats(options)
]
, render(res, subdomain)
);
// each of the function above returns another function, no simple API gotcha here
在浏览器案例中,错误在 fetch 函数中被正确识别,然后在渲染案例中也是如此。
在 mocha 案例中,错误在 fetch 函数中被正确识别,但未执行渲染。因此,mocha 一定是做了自己的 res.render("not found");
有什么想法吗?
【问题讨论】:
标签: javascript asynchronous mocha.js nimble