【问题标题】:Mocha conflicting with Nimble (Async)Mocha 与 Nimble 冲突(异步)
【发布时间】: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


    【解决方案1】:

    我是个笨蛋。

    忘记设置接受头。

    但我仍然很困惑为什么我追踪到相同的代码却得到了不同的行为。

    【讨论】:

      猜你喜欢
      • 2020-01-26
      • 1970-01-01
      • 2018-03-06
      • 2014-10-24
      • 2018-08-10
      • 2015-07-27
      • 1970-01-01
      • 2014-02-08
      • 2020-03-26
      相关资源
      最近更新 更多