7

Is there an equivalent to webmock or vcr for client side code? ... Or is it possible to use webmock with client side code already?

Christian Schlensker
  • 20,328
  • 18
  • 70
  • 118

3 Answers3

3

You can use sinon's FakeXMLHttpRequest, or nock.

Milovan Zogovic
  • 1,491
  • 1
  • 15
  • 23
0

Nowadays, try Mockttp.

It can mock requests for both Node & browser, it uses real requests thereby giving you far more accurate results than Nock et al, and it can either mock as a fake server (reconfiguring your target URLs) or an intercepting proxy (making requests to the real URLs, and intercepting some/all of them).

It's also got good support for running tests in parallel, which global-mocking libraries can't do, and lots of other nice modern features.

Tim Perry
  • 10,119
  • 49
  • 74