mardi 26 septembre 2017

How to access request properties on nock

I am trying to test the request URL that gets called on nock but couldn't figure out how get access to it. The code looks like this:

nock(host).get(`/user/${user_uuid}`).reply(200, res);

user.searchByUUID(user_uuid).then( response => {
  //todo: test request url, no request object?
  expect(response.data).toEqual(res.data)
  done();
});

I've created a ticket on github but unfortunately gr2m's reply doesn't solve the problem since the path that gets returned is the interceptor path rather than request's path.

Example: requesting path http://localhost:8080/user/1023 should show all the request's properties (headers, url, etc.) and not nock's headers and url.

Aucun commentaire:

Enregistrer un commentaire