xhr2-test

Monkey-patch the xhr2 library for testing.

Usage no npm install needed!

<script type="module">
  import xhr2Test from 'https://cdn.skypack.dev/xhr2-test';
</script>

README

xhr2-test

Monkey-patch the xhr2 library for testing.

If you are using xhr2 to test your AJAX code in a Node context, then this tool might be for you. It allows you to add an arbitrary prefix to any URL requested by xhr2. Most likely, you would use this to forward all requests to a test server that provides a known response for a given request.

For example, if your code makes a request to https://api.foo.ly/bar, you can run xhr2-test http://localhost:8080/ to send the request to http://localhost:8080/https://api.foo.ly/bar instead.