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
  • 21,708
  • 19
  • 73
  • 121

3 Answers3

3

You can use sinon's FakeXMLHttpRequest, or nock.

Milovan Zogovic
  • 1,541
  • 2
  • 16
  • 24
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
  • 11,766
  • 1
  • 57
  • 85