Question

I'm using api-easy to implement end-to-end tests for a REST api. The library itself is quite nice, but debugging failing tests is harder than I had expected, but maybe I'm not using the right approach.

I had this problem: The test sent a "GET" to a server, which was currently unresponsive due to OutOfMemory. The request blocked forever, but I could not see it in the output, as only successful or failed tests are printed.

Is it possible dump all requests to stdout? A timeout option could also help to abort blocking tests (and make them fail).

My current approach is to patch the api-easy.js file to dump the requests to console:

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

The output contains the headers, the uri and the method:

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)

It is not a very nice solution, as I am patching the contents of the node_modules directory.


Api-easy internally uses vows to control its data flow. I also run the tests with vows (either directy or with grunt-vows). I already enabled verbose mode (vows -v --spec) but it is not enough to analyze blocking tasks. I can only see successful or failing tests.

Était-ce utile?

La solution

I extended api-easy to provide timeouts for request.

Here is my pull request: https://github.com/flatiron/api-easy/pull/59

Under the hood, easy-api uses the request library. My patch makes the timeout option of the request configurable from api-easy.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top