npm nock 13.0.0-beta.2
v13.0.0-beta.2

13.0.0-beta.2 (2020-04-04)

Bug Fixes

  • router: bring behavior of abort() inline with native Node (#1960) (5c1b937), closes #439

BREAKING CHANGES

  • Calling request.abort():

    • Use to always emit a 'socket hang up' error. Now only emits the error if abort is called between the 'socket' and 'response' events.
    • The emitted 'abort' event now happens on nextTick.
    • The socket is now only destroyed if the 'socket' event has fired, and now emits a 'close' event on nextTick that propagates though the request object.
    • request.aborted attribute is set to true instead of a timestamp. Changed in Node v11.0 https://github.com/nodejs/node/pull/20230
    • Calling write, end, or flushHeaders on an aborted request no longer emits an error.
      However, writing to a request that is already finished (ended) will emit a 'write after end' error.
  • Playback of a mocked responses will now never happen until the 'socket' event is emitted.
    The 'socket' event is still artificially set to emit on nextTick when a ClientRequest is created.
    This means in the following code the Scope will never be done because at least one tick needs
    to happen before any matched Interceptor is considered consumed.

    const scope = nock(...).get('/').reply()
    const req = http.get(...)
    scope.done()
    
latest releases: 13.0.4, 13.0.3, 13.0.2...
5 months ago