nodejitsu/mock-request

README syntax does not work in tests

Closed this issue · 1 comments

I was stuck on this for a few hours trying to get mock tests to run. The syntax displayed in the current README file does NOT work and tests using it to NOT pass. I kept getting errors about the "statusCode" being undefined. I finally gave up to hack the source and discovered that response actually accepts an Object with named keys instead of the parameters in order as shown in the README file.

So instead of this (as shown in the README):

var mockFn = mockRequest.mock()
.get('/not-here')
  .respond(404)
.run();

It is this:

var mockFn = mockRequest.mock()
.get('/not-here')
  .respond({
    statusCode: 404
  })
.run();

This project has been deprecated. We suggest using nock: http://github.com/flatiron/nock