Financial-Times / tako

🐙 A GitHub App that provides an API listing the repositories it is installed on.
MIT License
4 stars 0 forks source link

chore(deps): update dependency nock to v11 #164

Closed renovate[bot] closed 4 years ago

renovate[bot] commented 4 years ago

This PR contains the following updates:

Package Type Update Change
nock devDependencies major ^10.0.6 -> ^11.0.0

Release Notes

nock/nock ### [`v11.3.2`](https://togithub.com/nock/nock/releases/v11.3.2) [Compare Source](https://togithub.com/nock/nock/compare/057bbdf906b35ea26ff8ae1e2dc3b4272ca9634b...v11.3.2) #### Upgrading from Nock 10 to Nock 11 ##### Bug fixes and internal improvements Nock 11 includes many under-the-hood improvements, including a fully offline test suite and 100% test coverage. The codebase was also converted to ES6 syntax and formatted with Prettier. Leaning on the test coverage, some substantial refactors have begun. Many bug fixes are included. See the detailed changelog below or the [compare view][compare] for details. ##### Fabulous new features for developers 1. The library ships with TypeScript definitions. (Added in v11.3) 2. Add support for the `http.request` signatures added in Node 10.9 3. Scopes can be filtered using the system environment or any external factor using e.g. `.conditionally(() => true)` 4. In-flight modifications to headers are preserved in mock requests. 5. Recorded mocks can be stringified using custom code in the `afterRecord()` post-processing hook. When `afterRecord()` returns a string, the recorder will no longer attempt to re-stringify it. (Added in v11.3) 6. Reply functions passed to `.reply()` can now be async/promise-returning. 7. Specifying reply headers, either via `.reply()` or `.defaultReplyHeaders()`, can now be done consistently using an object, Map, or flat array. ##### Breaking changes For many developers no code changes will be needed. However, there are several minor changes to the API, and it's possible that you will need to update your code for Nock to keep working properly. It's unlikely that your tests will falsely pass; what's more probable is that your tests will fail until the necessary changes are made. 1. Nock 11 requires Node 8 or later. Nock supports and tests all the "current" and "maintenance" versions of Node. As of now, that's Node 8, 10, and 12. 2. In Nock 10, when `reply()` was invoked with a function, the return values were handled ambiguously depending on their types. Consider the following example: ```js const scope = nock('http://example.com') .get('/') .reply(200, () => [500, 'hello world']) ``` In Nock 10, the 200 was ignored, the 500 was interpreted as the status code, and the body would contain `'hello world'`. This caused problems when the goal was to return a numeric array, so in Nock 11, the 200 is properly interpreted as the status code, and `[500, 'hello world']` as the body. These are the correct calls for Nock 11: ```js const scope = nock('http://example.com') .get('/') .reply(500, 'hello world') const scope = nock('http://example.com') .get('/') .reply(500, () => 'hello world') ``` The `.reply()` method can be called with explicit arguments: ```js .reply() // `statusCode` defaults to `200`. .reply(statusCode) // `responseBody` defaults to `''`. .reply(statusCode, responseBody) // `headers` defaults to `{}`. .reply(statusCode, responseBody, headers) ``` It can be called with a status code and a function that returns an array: ```js .reply(statusCode, (path, requestBody) => responseBody) .reply(statusCode, (path, requestBody) => responseBody, headers) ``` Alternatively the status code can be included in the array: ```js .reply((path, requestBody) => [statusCode]) .reply((path, requestBody) => [statusCode, responseBody]) .reply((path, requestBody) => [statusCode, responseBody, headers]) .reply((path, requestBody) => [statusCode, responseBody], headers) ``` `.reply()` can also be called with an `async` or promise-returning function. The signatures are identical, e.g. ```js .reply(async (path, requestBody) => [statusCode, responseBody]) .reply(statusCode, async (path, requestBody) => responseBody) ``` Finally, an error-first callback can be used, e.g.: ```js .reply((path, requestBody, cb) => cb(undefined, [statusCode, responseBody])) .reply(statusCode, (path, requestBody, cb) => cb(undefined, responseBody)) ``` 3. In Nock 10, errors in user-provided reply functions were caught by Nock, and generated HTTP rersponses with status codes of 500. In Nock 11 these errors are not caught, and instead are re-emitted through the request, like any other error that occurs during request processing. Consider the following example: ```js const scope = nock('http://example.com') .post('/echo') .reply(201, (uri, requestBody, cb) => { fs.readFile('cat-poems.txt', cb) // Error-first callback }) ``` When `fs.readFile()` errors in Nock 10, a 500 error was emitted. To get the same effect in Nock 11, the example would need to be rewritten to: ```js const scope = nock('http://example.com') .post('/echo') .reply((uri, requestBody, cb) => { fs.readFile('cat-poems.txt', (err, contents) => { if (err) { cb([500, err.stack]) } else { cb([201, contents]) } }) }) ``` 4. When `.reply()` is invoked with something other than a whole number status code or a function, Nock 11 raises a new error **Invalid ... value for status code**. 5. Callback functions provided to the `.query` method now receive the result of [`querystring.parse`](https://nodejs.org/api/querystring.html#querystring_querystring_parse_str_sep_eq_options) instead of [`qs.parse`](https://togithub.com/ljharb/qs#parsing-objects). In particular, `querystring.parse` does not interpret keys with JSON path notation: ```js querystring.parse('foo[bar]=baz') // { "foo[bar]": 'baz' } qs.parse('foo[bar]=baz') // { foo: { bar: 'baz' } } ``` 6. In Nock 10, duplicate field names provided to the `.query()` method were silently ignored. We decided this was probably hiding unintentionally bugs and causing frustration with users. In Nock 11, attempts to provide query params more than once will throw a new error **Query parameters have aleady been defined**. This could happen by calling `.query()` twice, or by calling `.query()` after specifying a literal query string via the path. ```js nock('http://example.com') .get('/path') .query({ foo: 'bar' }) .query({ baz: 'qux' }) // <-- will throw .reply() nock('http://example.com') .get('/path?foo=bar') .query({ baz: 'qux' }) // <-- will throw .reply() ``` 7. Paths in Nock have always required a leading slash. e.g. ```js const scope = nock('http://example.com') .get('/path') .reply() ``` In Nock 10, if the leading slash was missing the mock would never match. In Nock 11, this raises an error. 8. The `reqheaders` parameter should be provided as a plain object, e.g. `nock('http://example.com', { reqheaders: { X-Foo: 'bar' }})`. When the headers are specified incorrectly as e.g. `{ reqheaders: 1 }`, Nock 10 would behave in unpredictable ways. In Nock 11, a new error **Headers must be provided as an object** is thrown. ```js nock('http://example.com', { reqheaders: 1 }) .get('/') .reply() ``` 9. In Nock 10, the `ClientRequest` instance wrapped the native `on` method and aliased `once` to it. In Nock 11, this been removed and `request.once` will correctly call registered listeners...once. 10. In Nock 10, when the method was not specified in a call to `nock.define()`, the method would default `GET`. In Nock 11, this raises an error. 11. In very old versions of nock, recordings may include a response status code encoded as a string in the `reply` field. In Nock 10 these strings could be non-numeric. In Nock 11 this raises an error. ##### Updates to the mock surface 1. For parity with a real response, a mock request correctly supports all the overrides to `request.end()`, including `request.end(cb)` in Node 12. 2. For parity with a real response, errors from the `.destroy()` method are propagated correctly. (Added in v11.3) 3. For parity with a real response, the `.complete` property is set when ending the response. 4. For parity with a real Socket, the mock Socket has an `unref()` function (which does nothing). [compare]: https://togithub.com/nock/nock/compare/v10.0.6...v11.3.0@​next If you discover bugs in this release, please [open a bug report][] on the Nock repo. 🐛 [open a bug report]: https://togithub.com/nock/nock/issues/new?template=01_bug_report.md * * * #### Detailed changelog
##### BREAKING CHANGES - uncaught errors thrown inside of user provided reply functions, whether async or not, will no longer be caught, and will no longer generate a successful response with a status code of 500. Instead, the error will be emitted by the request just like any other unhandled error during the request processing. - The only argument passed to the Interceptor.query callback now receives the output from querystring.parse instead of qs.parse. This means that instead of nested objects the argument will be a flat object. - **interceptor:** Attempting to call `Interceptor.query` twice throws an error. - **interceptor:** Providing a duplicate search parameter to the `query` method throws an error instead of ignoring subsequent values. - Drop support for Node 6 ##### Features - **interceptor:** duplicate query calls throw ([#​1630](https://togithub.com/nock/nock/issues/1630)) ([2a54482](https://togithub.com/nock/nock/commit/2a54482)), closes [#​1626](https://togithub.com/nock/nock/issues/1626) - **interceptor:** duplicate query keys throw ([a2208d1](https://togithub.com/nock/nock/commit/a2208d1)), closes [#​1623](https://togithub.com/nock/nock/issues/1623) - Throw error if request headers are not an object ([#​1574](https://togithub.com/nock/nock/issues/1574)) ([8ba0fc7](https://togithub.com/nock/nock/commit/8ba0fc7)) - **overrider:** added support for header modifications before end() ([4a4b8ec](https://togithub.com/nock/nock/commit/4a4b8ec)) - Add `conditionally()` ([#​1488](https://togithub.com/nock/nock/issues/1488)) ([24e5b47](https://togithub.com/nock/nock/commit/24e5b47)) - **reply:** Response headers to more closely match Node's functionality. ([#​1564](https://togithub.com/nock/nock/issues/1564)) ([b687592](https://togithub.com/nock/nock/commit/b687592)), closes [#​1553](https://togithub.com/nock/nock/issues/1553) [/github.com/nodejs/node/blob/908292cf1f551c614a733d858528ffb13fb3a524/lib/\_http_incoming.js#L245](https://togithub.com//github.com/nodejs/node/blob/908292cf1f551c614a733d858528ffb13fb3a524/lib/_http_incoming.js/issues/L245) - **request_overrider:** Set `IncomingMessage.client` for parity with real requests ([dc71a3b](https://togithub.com/nock/nock/commit/dc71a3b)), closes [/github.com/nodejs/node/blob/2e613a9c301165d121b19b86e382860323abc22f/lib/\_http_incoming.js#L67](https://togithub.com//github.com/nodejs/node/blob/2e613a9c301165d121b19b86e382860323abc22f/lib/_http_incoming.js/issues/L67) - **requestoverrider:** Add method property to mocked requests ([#​1561](https://togithub.com/nock/nock/issues/1561)) ([4857ae5](https://togithub.com/nock/nock/commit/4857ae5)) - added noop method `unref` to Socket ([#​1612](https://togithub.com/nock/nock/issues/1612)) ([a75f49f](https://togithub.com/nock/nock/commit/a75f49f)) - Support http.request signatures added in Node 10.9+ ([#​1588](https://togithub.com/nock/nock/issues/1588)) ([e3e6a65](https://togithub.com/nock/nock/commit/e3e6a65)), closes [#​1227](https://togithub.com/nock/nock/issues/1227) - Throw an error on invalid truthy reply status codes ([#​1571](https://togithub.com/nock/nock/issues/1571)) ([de525a1](https://togithub.com/nock/nock/commit/de525a1)) - Async Reply functions (always emit errors) ([#​1596](https://togithub.com/nock/nock/issues/1596)) ([26fc08f](https://togithub.com/nock/nock/commit/26fc08f)), closes [#​1596](https://togithub.com/nock/nock/issues/1596) - Drop support for Node 6 ([15b3cf0](https://togithub.com/nock/nock/commit/15b3cf0)), closes [#​1297](https://togithub.com/nock/nock/issues/1297) - types: Add Typescript definitions. ([#​1676](https://togithub.com/nock/nock/issues/1676)) ([`2e56fb0`](https://togithub.com/nock/nock/commit/2e56fb0)), closes [#​1670](https://togithub.com/nock/nock/issues/1670) - socket: propagate errors from destroy method ([#​1675](https://togithub.com/nock/nock/issues/1675)) ([`de9c40b`](https://togithub.com/nock/nock/commit/de9c40b)), closes [#​1669](https://togithub.com/nock/nock/issues/1669) ##### Bug Fixes - `req.end(cb)` compatibility with Node 12 ([#​1551](https://togithub.com/nock/nock/issues/1551)) ([31623fb](https://togithub.com/nock/nock/commit/31623fb)) - alias connection to socket. ([#​1590](https://togithub.com/nock/nock/issues/1590)) ([659bf01](https://togithub.com/nock/nock/commit/659bf01)), closes [/github.com/nodejs/node/blob/master/lib/\_http_client.js#L640-L641](https://togithub.com//github.com/nodejs/node/blob/master/lib/_http_client.js/issues/L640-L641) [/github.com/nodejs/node/blob/master/lib/\_http_incoming.js#L44-L45](https://togithub.com//github.com/nodejs/node/blob/master/lib/_http_incoming.js/issues/L44-L45) - allow unmocked when providing literal search params. ([#​1614](https://togithub.com/nock/nock/issues/1614)) ([f8d6cbb](https://togithub.com/nock/nock/commit/f8d6cbb)), closes [#​1421](https://togithub.com/nock/nock/issues/1421) - Fix `.matchHeader()` with `allowUnmocked` ([#​1480](https://togithub.com/nock/nock/issues/1480)) ([d6667f0](https://togithub.com/nock/nock/commit/d6667f0)) - Fix `req.end(cb)`; prevent TypeError in Node 12 ([#​1547](https://togithub.com/nock/nock/issues/1547)) ([9a494da](https://togithub.com/nock/nock/commit/9a494da)), closes [#​1509](https://togithub.com/nock/nock/issues/1509) - Mock responses should fire when timers are mocked ([#​1336](https://togithub.com/nock/nock/issues/1336)) ([a213169](https://togithub.com/nock/nock/commit/a213169)), closes [#​1335](https://togithub.com/nock/nock/issues/1335) [#​1334](https://togithub.com/nock/nock/issues/1334) - **define:** Throw error when legacy reply is in wrong format ([5d2fb9f](https://togithub.com/nock/nock/commit/5d2fb9f)) - package.engines is supposed to be an object ([6dc0208](https://togithub.com/nock/nock/commit/6dc0208)) - request.end accepted arguments ([#​1591](https://togithub.com/nock/nock/issues/1591)) ([ad34222](https://togithub.com/nock/nock/commit/ad34222)), closes [/github.com/nodejs/node/commit/a10bdb51b18dfaad874f3702a1daea51ec2d4514#diff-286202fdbdd74ede6f5f5334b6176b5cL779](https://togithub.com//github.com/nodejs/node/commit/a10bdb51b18dfaad874f3702a1daea51ec2d4514/issues/diff-286202fdbdd74ede6f5f5334b6176b5cL779) [#​1549](https://togithub.com/nock/nock/issues/1549) - response.complete must be true after res.end ([#​1601](https://togithub.com/nock/nock/issues/1601)) ([2c4edba](https://togithub.com/nock/nock/commit/2c4edba)) - Restore behavior of Interceptor.filteringPath ([#​1543](https://togithub.com/nock/nock/issues/1543)) ([560a5d8](https://togithub.com/nock/nock/commit/560a5d8)) - throw error when leading slash is not present in path ([#​1391](https://togithub.com/nock/nock/issues/1391)) ([28b2d43](https://togithub.com/nock/nock/commit/28b2d43)), closes [/github.com/nock/nock/pull/1391#discussion_r250725610](https://togithub.com//github.com/nock/nock/pull/1391/issues/discussion_r250725610) - **socket:** When Socket#setTimeout gets a callback, should still emit ([a07b0ba](https://togithub.com/nock/nock/commit/a07b0ba)), closes [#​1404](https://togithub.com/nock/nock/issues/1404) - trigger release ([#​1645](https://togithub.com/nock/nock/issues/1645)) ([88e85ac](https://togithub.com/nock/nock/commit/88e85ac)) - Update and clarify how .reply() can be invoked with functions ([#​1520](https://togithub.com/nock/nock/issues/1520)) ([2e779f0](https://togithub.com/nock/nock/commit/2e779f0)), closes [/github.com/nock/nock/pull/1517/files#r280139478](https://togithub.com//github.com/nock/nock/pull/1517/files/issues/r280139478) [#​1222](https://togithub.com/nock/nock/issues/1222) - **define:** Throw when method is missing ([69ba3c3](https://togithub.com/nock/nock/commit/69ba3c3)) - **intercept:** Better error message when options is falsy ([#​1440](https://togithub.com/nock/nock/issues/1440)) ([7e44769](https://togithub.com/nock/nock/commit/7e44769)) - **intercept:** Improve error message when `new ClientMessage()` is invoked with no options ([#​1386](https://togithub.com/nock/nock/issues/1386)) ([6d2a312](https://togithub.com/nock/nock/commit/6d2a312)) - **package:** update propagate to version 2.0.0 ([b729466](https://togithub.com/nock/nock/commit/b729466)) - **recorder:** allow recording req headers when not outputting objects ([#​1617](https://togithub.com/nock/nock/issues/1617)) ([a952d9b](https://togithub.com/nock/nock/commit/a952d9b)), closes [/nodejs.org/api/deprecations.html#deprecations_dep0066](https://togithub.com//nodejs.org/api/deprecations.html/issues/deprecations_dep0066) ##### Code Refactoring - overhaul body and query matching ([#​1632](https://togithub.com/nock/nock/issues/1632)) ([35221ce](https://togithub.com/nock/nock/commit/35221ce)), closes [#​507](https://togithub.com/nock/nock/issues/507) [#​1552](https://togithub.com/nock/nock/issues/1552)
### [`v11.3.1`](https://togithub.com/nock/nock/compare/e0930f8912e62d4dc71f2b7ea24faa00568adb78...057bbdf906b35ea26ff8ae1e2dc3b4272ca9634b) [Compare Source](https://togithub.com/nock/nock/compare/e0930f8912e62d4dc71f2b7ea24faa00568adb78...057bbdf906b35ea26ff8ae1e2dc3b4272ca9634b) ### [`v11.3.0`](https://togithub.com/nock/nock/compare/de9c40be64dab30d87c548b8e30ef667f4610b08...e0930f8912e62d4dc71f2b7ea24faa00568adb78) [Compare Source](https://togithub.com/nock/nock/compare/de9c40be64dab30d87c548b8e30ef667f4610b08...e0930f8912e62d4dc71f2b7ea24faa00568adb78) ### [`v11.2.0`](https://togithub.com/nock/nock/compare/v11.1.0...de9c40be64dab30d87c548b8e30ef667f4610b08) [Compare Source](https://togithub.com/nock/nock/compare/v11.1.0...de9c40be64dab30d87c548b8e30ef667f4610b08) ### [`v11.1.0`](https://togithub.com/nock/nock/compare/11dba990de94629189dca1030669f2d6d8d409f9...v11.1.0) [Compare Source](https://togithub.com/nock/nock/compare/11dba990de94629189dca1030669f2d6d8d409f9...v11.1.0) ### [`v11.0.0`](https://togithub.com/nock/nock/compare/v10.0.6...11dba990de94629189dca1030669f2d6d8d409f9) [Compare Source](https://togithub.com/nock/nock/compare/v10.0.6...11dba990de94629189dca1030669f2d6d8d409f9)

Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "rebase!".

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.



This PR has been generated by Renovate Bot. View repository job log here.