You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The devDependency nock was updated from 10.0.6 to 11.1.0.
This version is not covered by your current version range.
If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.
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 for details.
Fabulous new features for developers
The library ships with TypeScript definitions. (Added in v11.3)
Add support for the http.request signatures added in Node 10.9
Scopes can be filtered using the system environment or any external factor
using e.g. .conditionally(() => true)
In-flight modifications to headers are preserved in mock requests.
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)
Reply functions passed to .reply() can now be async/promise-returning.
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.
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.
In Nock 10, when reply() was invoked with a function, the return values were
handled ambiguously depending on their types.
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.
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.
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.
Callback functions provided to the .query method now receive the result of querystring.parse
instead of qs.parse.
In particular, querystring.parse does not interpret keys with JSON
path notation:
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.
In Nock 10, if the leading slash was missing the mock would never match. In
Nock 11, this raises an error.
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.
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.
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.
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
For parity with a real response, a mock request correctly supports all
the overrides to request.end(), including request.end(cb) in Node 12.
For parity with a real response, errors from the .destroy() method
are propagated correctly. (Added in v11.3)
For parity with a real response, the .complete property is set when
ending the response.
For parity with a real Socket, the mock Socket has an unref() function
(which does nothing).
If you discover bugs in this release, please open a bug report on the Nock repo. 🐛
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.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The devDependency nock was updated from
10.0.6
to11.1.0
.This version is not covered by your current version range.
If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.
Publisher: nockbot
License: MIT
Find out more about this release.
FAQ and help
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper bot 🌴