Skip to content

Releases: mswjs/interceptors

v0.4.0

20 Aug 08:48
Compare
Choose a tag to compare

Breaking changes

  • Creating a new RequestInterceptor instance now requires to pass a list of interceptors to use. It's recommended to use the /presets/default interceptors preset for backwards-compatibility.
import { RequestInterceptor } from 'node-request-interceptor'
+import withDefaultInterceptors from 'node-request-interceptor/presets/default'

-new RequestInterceptor()
+new RequestInterceptor(withDefaultInterceptors)

Features

  • Supports granular interceptors configuration (#48), allowing to specify which request issuing modules to intercept on the usage level. The list of published interceptors:

    • node-request-interceptor/interceptors/ClientRequest
    • node-request-interceptor/interceptors/XMLHttpRequest

To use one or multiple interceptors import them and provide as an argument to RequestInterceptor class:

import { RequestInterceptor } from 'node-request-interceptor'
import { interceptXMLHttpRequest } from 'node-request-interceptor/interceptors/XMLHttpRequest'

const interceptor = new RequestInterceptor([interceptXMLHttpRequest])
interceptor.use(/* refer to README for usage examples */)

Bug fixes

  • Fixes an issue that didn't respect the timeout property on the XMLHttpRequest (#43).
  • Fixes an issue that resulted into broken arguments forwarding when using xhr.open() (#42).

v0.3.6

18 Aug 06:40
Compare
Choose a tag to compare

Changes

ClientRequest

  • options.uri.protocol is taken into account when deciding on the request's protocol.

XMLHttpRequest

  • this.user and this.password initializers are now removed, the values default to undefined.
  • this.async has a default value of undefined, true when forwarded (previously false).

Bug fixes

  • Fixes an issue when the timeout property of an XMLHttpRequest was not propagated to the original request (#47, #43).
  • Fixes an issue when a forwarded xhrRequest.open() call did not have the right async parameter value (#42).

v0.3.5

10 Aug 09:45
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issue that resulted in ProgressEvent throwing an exception in React Native environment due to not being defined there (#40, #41).

v0.3.4

09 Aug 08:15
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issue that resulted into http module override being loaded in React Native (#37).

v0.3.3

16 Jul 13:13
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issue that resulted into a mocked statusText not being set on the ClientRequest instance (mswjs/msw#279, #35).

v0.3.2

14 Jul 08:59
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issue where a request body and encoding where not accepted in the ClientRequest.prototype.end method (#32, #33).
  • Fixes an issue where request headers that were added after the ClientRequest has been constructed were not present on the mocked request object, and were not propagated to the original request object (#32, #33).

v0.3.1

14 Jul 08:58
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issue where events added via XMLHttpRequest.prototype.addEventListener were not called (#31)

v0.3.0

08 Jul 07:39
Compare
Choose a tag to compare

Features

  • Throwing an exception in a request middleware function now produces a valid request error (network error) and cancels a pending request (#28, #29).

Bug fixes

  • Fixes an issue that resulted into a custom callback function to http/https request being called twice (#26).

Internal

  • Improves request debugging by attaching request method and URL to the debug statements (#23, #30).

v0.2.6

15 Jun 07:19
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issue that resulted into a req.url instance not having any username and password information, although performed an authenticated request (via RequestOptions.auth) (#21).

v0.2.5

13 Jun 09:47
Compare
Choose a tag to compare

Bug fixes

  • Fixes an issues that resulted into TypeError: Cannot read property 'apply' of undefined exception when using certain third-party request issuing libraries (#19, #20). Resolved by implementing setNoDelay, setKeepAlive and setTimeout on the polyfilled Socket class.