jameslnewell / xhr-mock

Utility for mocking XMLHttpRequest.
196 stars 48 forks source link

Adds way to get request headers #9

Closed wpjunior closed 8 years ago

orbiteleven commented 8 years ago

Great idea! Tests perhaps?

jameslnewell commented 8 years ago

Thanks for the PR!

What's the use case for this addition? It doesn't look like a standard method on the XMLHttpRequest interface and you can already check the request headers before returning a response e.g.

mock.get('http://localhost/api/user', function(req, res) {
  console.log(req.header('content-type'));
  return res;
});
zachelrath commented 8 years ago

@jameslnewell I agree - MockXMLHttpRequest should just implement the XMLHttpRequest interface, there's no practical need for this additional method.

jameslnewell commented 8 years ago

ping @wpjunior