摩卡与敏捷(异步)冲突

Mocha conflicting with Nimble (Async)

本文关键字:异步 冲突 摩卡      更新时间:2023-09-26

我在我的应用程序中使用nimble.js和mocha + chai进行测试,但昨天我发现它们可能冲突。

基本上,当我在浏览器中执行特定的http请求时,我得到

Unauthorized.

这是正确的响应。

但是使用节点的 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

在浏览器的情况下,错误在获取函数中被正确识别,然后在渲染情况下也被正确识别。

在 mocha 案例中,在获取函数中正确识别了错误,但未执行渲染。因此,摩卡必须做了自己的 res.render("未找到");

有什么想法吗?

我是个的白痴。

忘记设置接受标头。

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