Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency nock to v13 #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

renovate[bot]
Copy link

@renovate renovate bot commented Jul 5, 2020

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
nock 2.17.0 -> 13.5.6 age adoption passing confidence

Release Notes

nock/nock (nock)

v13.5.6

Compare Source

Bug Fixes

v13.5.5

Compare Source

v13.5.4

Compare Source

Bug Fixes

v13.5.3

Compare Source

Bug Fixes

v13.5.2

Compare Source

Bug Fixes
  • remove duplicates from activeMocks() and pendingMocks() (#​2356) (7e957b3)

v13.5.1

Compare Source

Bug Fixes

v13.5.0

Compare Source

Features

v13.4.0

Compare Source

Features

v13.3.8

Compare Source

Bug Fixes

v13.3.7

Compare Source

Reverts

v13.3.6

Compare Source

Bug Fixes

v13.3.5

Compare Source

Bug Fixes

v13.3.4

Compare Source

Bug Fixes
  • typescript: support nock(new URL('https://example.test/')) (#​2526) (6987327)

v13.3.3

Compare Source

Bug Fixes

v13.3.2

Compare Source

Bug Fixes
  • nock.removeInterceptor can remove the wrong Intercept (#​2497) (92de0de)

v13.3.1

Compare Source

Bug Fixes

v13.3.0

Compare Source

Features

v13.2.9

Compare Source

Bug Fixes
  • README: Add notes about Scope vs Interceptor matchHeader calls (#​2382) (d9bab65)

v13.2.8

Compare Source

Bug Fixes
  • types: allow regexp on Definition#scope and Definition#path (#​2374) (2edf341)

v13.2.7

Compare Source

Bug Fixes

v13.2.6

Compare Source

Reverts

v13.2.5

Compare Source

Bug Fixes

v13.2.4

Compare Source

Bug Fixes

v13.2.3

Compare Source

Bug Fixes

v13.2.2

Compare Source

Bug Fixes
  • allowUnocked not working with regex host + request body match (#​2277) (ac7b4fd)

v13.2.1

Compare Source

Bug Fixes

v13.2.0

Compare Source

Features

v13.1.4

Compare Source

Bug Fixes

v13.1.3

Compare Source

Bug Fixes

v13.1.2

Compare Source

Bug Fixes

v13.1.1

Compare Source

Bug Fixes
  • types: allow readonly arrays for data matcher in types (#​2215) (940f4b7)

v13.1.0

Compare Source

Features

v13.0.11

Compare Source

Bug Fixes
  • interceptor: don't require leading slash if Scope has a base pathname (#​2168) (bfbbbb7)

v13.0.10

Compare Source

Bug Fixes

v13.0.9

Compare Source

Bug Fixes
  • playback: consistently check for destroyed attribute (#​2152) (b9758c8)

v13.0.8

Compare Source

Bug Fixes

v13.0.7

Compare Source

Bug Fixes
  • recorder: escape single quotes in path of default output (#​2137) (0f7b52e)

v13.0.6

Compare Source

Bug Fixes

v13.0.5

Compare Source

Bug Fixes

v13.0.4

Compare Source

Bug Fixes
  • Parallel requests on same Interceptor are exposed correctly in reply functions (#​2056) (6260217)

v13.0.3

Compare Source

Bug Fixes

v13.0.2

Compare Source

Bug Fixes

v13.0.1

Compare Source

Bug Fixes

v13.0.0

Compare Source

See the Migration Guide

Breaking changes
  1. Scope.log has been removed. Use the debug library when debugging failed matches.

  2. socketDelay has been removed. Use delayConnection instead.

  3. delay, delayConnection, and delayBody are now setters instead of additive.

  4. When recording, skipping body matching using * is no longer supported by nock.define.
    Set the definition body to undefined instead.

  5. ClientRequest.abort() has been updated to align with Node's native behavior.
    This could be considered a feature, however, it created some subtle differences that are not backwards compatible. Refer to the migration guide for details.

  6. Playback of a mocked responses will now never happen until the 'socket' event is emitted.

v12.0.3

Compare Source

Bug Fixes

v12.0.2

Compare Source

Bug Fixes

v12.0.1

Compare Source

Bug Fixes

v12.0.0

Compare Source

BREAKING CHANGES

When checking types of strings, Nock will no longer recognize the String constructor, only string primitives.

Features

v11.9.1

Compare Source

Bug Fixes
  • revert breaking changes from v11.9.0 (062c10e)

v11.9.0

Compare Source

Features

v11.8.2

Compare Source

Bug Fixes

v11.8.1

Compare Source

Bug Fixes

v11.8.0

Compare Source

Bug Fixes
Features

v11.7.2

Compare Source

Bug Fixes
  • Fix a regression due to Jest having different globals (#​1850) (c7363e5)

v11.7.1

Compare Source

Bug Fixes

v11.7.0

Compare Source

Features

v11.6.0

Compare Source

Features

v11.5.0

Compare Source

Features

v11.4.0

Compare Source

Features

v11.3.6

Compare Source

Bug Fixes

v11.3.5

Compare Source

Bug Fixes

v11.3.4

Compare Source

Bug Fixes

v11.3.3

Compare Source

Bug Fixes

v11.3.2: v11

Compare Source

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 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:

    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:

    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:

    .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:

    .reply(statusCode, (path, requestBody) => responseBody)
    .reply(statusCode, (path, requestBody) => responseBody, headers)

    Alternatively the status code can be included in the array:

    .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.

    .reply(async (path, requestBody) => [statusCode, responseBody])
    .reply(statusCode, async (path, requestBody) => responseBody)

    Finally, an error-first callback can be used, e.g.:

    .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 responses 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:

    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:

    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 instead of qs.parse.

    In particular, querystring.parse does not interpret keys with JSON
    path notation:

    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.

    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.

    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.

    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 to 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).

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.
  • Drop support for Node 6
Features
Bug Fixes
Code Refactoring

v11.3.1

Compare Source

v11.3.0

Compare Source

v11.2.0

Compare Source

v11.1.0

Compare Source

v11.0.0

Compare Source

v10.0.6

Compare Source

Bug Fixes

v10.0.5

Compare Source

Bug Fixes
  • package.engines shows incorrect versions and is supposed to be an object (0c4edd6)

v10.0.4

Compare Source

Bug Fixes

v10.0.3

Compare Source

Bug Fixes

v10.0.2

Compare Source

Bug Fixes

v10.0.1

Compare Source

Bug Fixes

v10.0.0

Compare Source

BREAKING CHANGES
  • drop official support for Node < 6

There is no intentional change that breaks usage in Node 4, but as we
stop testing in this no longer supported Node version we recommend to
no update nock if you still rely on Node 4.

The reason why we decided to go ahead and make a breaking version
release is that it became increasingly harder to update dependencies
to the latest versions as they also drop support for Node 4.

Bug Fixes
Code Refactoring
  • update Buffer constructors to from and alloc (c94b89d)
Continuous Integration
  • travis: stop testing in Node 4 (139b632)

v9.6.1

Compare Source

Bug Fixes
  • set socket connecting state to always be false (ca1eea0)

v9.6.0

Compare Source

Features
  • Allow optionally() to be called with a value, specifying if the mock should be optional (d8a2606)

v9.5.0

Compare Source

Features
  • encode an expected buffer the same way when matching as the client (c584f7a)

v9.4.4

Compare Source

Bug Fixes

v9.4.3

Compare Source

Bug Fixes

v9.4.2

Compare Source

Bug Fixes
  • Replaced util._extend with Object.assign due to deprecated since node v6. (7fd2329)

v9.4.1

Compare Source

Bug Fixes
  • request overrider checks req.headers to parse body as JSON (#​1157) (f81fb6d)

v9.4.0

Compare Source

Features

v9.3.3

Compare Source

Bug Fixes

v9.3.2

Compare Source

Bug Fixes

v9.3.1

Compare Source

Bug Fixes

v9.3.0

Compare Source

Features

v9.2.6

Compare Source

Bug Fixes

v9.2.5

Compare Source

Bug Fixes
  • remove arrow functions to restore Node<4 compatibility (#​1114) (11f1a25)

v9.2.4

Compare Source

Bug Fixes

v9.2.3

Compare Source

Bug Fixes

v9.2.2

Compare Source

Bug Fixes

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

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

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

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


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
Copy link
Author

renovate bot commented Mar 24, 2023

⚠ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: package-lock.json

@renovate renovate bot changed the title Update dependency nock to v13 Update dependency nock to v13 - autoclosed Apr 4, 2023
@renovate renovate bot closed this Apr 4, 2023
@renovate renovate bot deleted the renovate/nock-13.x branch April 4, 2023 00:23
@renovate renovate bot changed the title Update dependency nock to v13 - autoclosed Update dependency nock to v13 Apr 4, 2023
@renovate renovate bot reopened this Apr 4, 2023
@renovate renovate bot restored the renovate/nock-13.x branch April 4, 2023 08:25
@renovate renovate bot force-pushed the renovate/nock-13.x branch 2 times, most recently from 522073d to 6a07006 Compare November 3, 2023 06:32
Copy link
Author

renovate bot commented Aug 20, 2024

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: package-lock.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants