【问题标题】:How to debug hanging api-easy (or vows) tests?如何调试挂起的 api-easy(或 vows)测试?
【发布时间】:2014-05-15 14:01:27
【问题描述】:

我正在使用api-easy 来实现 REST api 的端到端测试。该库本身非常好,但调试失败的测试比我预期的要难,但也许我没有使用正确的方法。

我遇到了这个问题:测试向服务器发送了“GET”,由于内存不足,该服务器当前无响应。该请求永远被阻止,但我在输出中看不到它,因为只打印成功或失败的测试。

是否可以将所有请求转储到标准输出?超时选项还可以帮助中止阻塞测试(并使它们失败)。

我目前的方法是修补 api-easy.js 文件以将请求转储到控制台:

  console.log(outgoing); // this line is new
  if (requestImpl)
    requestImpl(outgoing, this.callback);
  else
    request(outgoing, this.callback);

输出包含标头、uri 和方法:

Dummy "echo" REST service 

{ headers: { 'Content-Type': 'application/json' },
  uri: 'http://localhost/resources/echo/abc',
  method: 'get' }
  When using the "echo" service A GET to /echo/abc
   ✓ should respond with 200
   ✓ should respond with {"echo":"abc"}

vows runner finish 
✓ OK » 2 honored (0.024s)

这不是一个很好的解决方案,因为我正在修补 node_modules 目录的内容。


Api-easy 内部使用vows 来控制其数据流。我还使用誓言(直接或使用 grunt-vows)运行测试。我已经启用了详细模式(vows -v --spec),但不足以分析阻塞任务。我只能看到成功或失败的测试。

【问题讨论】:

    标签: node.js debugging vows


    【解决方案1】:

    我扩展了 api-easy 以提供请求超时。

    这是我的拉取请求: https://github.com/flatiron/api-easy/pull/59

    在底层,easy-api 使用request library。我的补丁使请求的超时选项可从 api-easy 进行配置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-03
      • 2011-10-18
      • 2011-11-07
      相关资源
      最近更新 更多