Tags: Alexsey/nock
Tags
feature: remove Scope.log in favor of more debug (nock#1966) Consolidates the behavior around debugging and logging to exclusively use [`debug`](https://github.com/visionmedia/debug). The use of `scope.log(console.log)` was problematic and confusing for consumers as that appeared to be the correct approach when debugging unless they found the correct section in the README. The use of the logger vs directly using `debug` in the core of Nock was inconsistent, especially when matching. Now any failure to match a request will be directed to `debug` and if a single Interceptor is in context, the namespace in the log will include the host from the Scope. This allows for filtering of logs to stdout as well as differentiating colors from `debug`, when enabled. BREAKING CHANGE: `Scope.log` has been removed. Use the `debug` library when [debugging](https://github.com/nock/nock#debugging) failed matches.
fix(router): bring behavior of `abort()` inline with native Node (noc… …k#1960) Nocks behavior around events and errors relating to aborting and ending requests has not lined up with Node for while. I dug into an investigation of how it differs, if there were git commits/pull-requests explaining why they differ, and trying to answer the question of should Nock change to line up better. The single largest deviation were the errors emitted around aborting or already aborted requests. Emitting an error on abort was added to fix issue nock#439. The conversation talks about how Node emits an error post abort. > ... in practice the `http` module does emit an `ECONNRESET` error after aborting. ... - Jan 7, 2016 However, this is only true between the 'socket' and 'response' events. Otherwise calling abort does not emit an error of any kind. Determining exactly what Nock should do is a bit of moving target. As Node's internals of HTTP, Net, Stream, and micro task timing have changed a lot since iojs/v4, when Nock added these errors, and v13, current at this time. My conclusion is that none of Nock's deviations from Node's _documented_ behavior are user features that should be maintained. If anything, bringing Nock closer to Node better fulfills original requests. nock#282 The entire `test_abort.js` file was scraped and rewritten by writing assertions against Node behavior, without Nock first. Then adding Nock into each test to ensure events and errors were correct. BREAKING CHANGE: 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 nodejs/node#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. ```js const scope = nock(...).get('/').reply() const req = http.get(...) scope.done() ```
chore: remove body matching using "*" using definitions (nock#1964) * chore: remove body matching using "*" using definitions BREAKING CHANGE: Skipping body matching using "*" is no longer supported. Set the definition `body` to `undefined` instead.
fix(router): stall finish event to avoid dup (nock#1954) * fix(router): stall finish event to avoid dup Delays the emitting of the "finish" event on the request until it knows for sure an Interceptor is going to playback. This stops a double emit for unmocked requests. Also removes the "end" event from firing on the request. This event was added in the first commit with code for Nock and was used to kicked off the internals that now live in `startPlayback`. nock@31a500c#diff-503754c07b5098227646f913eee85885R27-R76 closes nock#1832
test: Update got to the latest version and fill in missing coverage (n… …ock#1825) * chore(package): update got to version 10.0.0 * chore(package): update lockfile package-lock.json * Bump got again and run npm install * query -> searchParams * encoding -> responseType * `{body: …}` no longer implies `.post()` * auth -> username + password * query -> searchParams * Error now has a `response` property * Couple other fixes * Restore 100% coverage * Update lockfile * refactor(test): use Mocha DSL for allow unmocked (nock#1894) * refactor(test): use Mocha DSL for allow unmocked * Fix format * baseUrl -> prefixUrl * Update json’s for breaking changes * update usage of prefixUrl. There was a subtle, and I think unnecessary, change in Got 10.x where using `prefixUrl` means the input, when making a request, can no longer have a leading slash. The prefix value can optionally have a trailing slash. https://github.com/sindresorhus/got#prefixurl Co-authored-by: Paul Melnikow <github@paulmelnikow.com> Co-authored-by: Matt R. Wilson <github@mattw.co>
test: Update got to the latest version and fill in missing coverage (n… …ock#1825) * chore(package): update got to version 10.0.0 * chore(package): update lockfile package-lock.json * Bump got again and run npm install * query -> searchParams * encoding -> responseType * `{body: …}` no longer implies `.post()` * auth -> username + password * query -> searchParams * Error now has a `response` property * Couple other fixes * Restore 100% coverage * Update lockfile * refactor(test): use Mocha DSL for allow unmocked (nock#1894) * refactor(test): use Mocha DSL for allow unmocked * Fix format * baseUrl -> prefixUrl * Update json’s for breaking changes * update usage of prefixUrl. There was a subtle, and I think unnecessary, change in Got 10.x where using `prefixUrl` means the input, when making a request, can no longer have a leading slash. The prefix value can optionally have a trailing slash. https://github.com/sindresorhus/got#prefixurl Co-authored-by: Paul Melnikow <github@paulmelnikow.com> Co-authored-by: Matt R. Wilson <github@mattw.co>
Version bump (nock#1898) BREAKING CHANGE: Fix version number for breaking changes
PreviousNext