File: migrating_to_12.md

package info (click to toggle)
node-nock 13.5.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,168 kB
  • sloc: javascript: 12,018; makefile: 11
file content (33 lines) | stat: -rw-r--r-- 1,257 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
## Upgrading from Nock 11 to Nock 12

[Release Tag](https://github.com/nock/nock/releases/tag/v12.0.0)

### Breaking changes

1. Support for Node < 10 was dropped.  
   To upgrade Nock, ensure your version of Node is also updated.  
   At the time of release, Node 10.x, 12.x, and 13.x were supported.

1. [`cleanAll()`](https://github.com/nock/nock#cleanall) no longer returns the global `nock` instance ([#1872](https://github.com/nock/nock/pull/1872)).

   ```js
   // before
   nock.cleanAll().restore() // Uncaught TypeError: Cannot read property 'restore' of undefined

   // upgraded
   nock.cleanAll()
   nock.restore()
   ```

1. Support was dropped for the String constructor ([#1873](https://github.com/nock/nock/pull/1873)).  
   Only string primitive are supported. All strings passed to Nock for options should not use `new String` syntax.
   [MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#String_primitives_and_String_objects).

### New features for developers

1.  [`enableNetConnect()`](https://github.com/nock/nock#enabling-requests) now accepts a function.
    ```js
    nock.enableNetConnect(
      host => host.includes('amazon.com') || host.includes('github.com'),
    )
    ```