nock 13.3.1 → 13.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/lib/intercept.js +12 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
[npmjs]: https://www.npmjs.com/package/nock
|
|
10
10
|
[build]: https://travis-ci.org/nock/nock
|
|
11
11
|
|
|
12
|
+
> **Warning**
|
|
13
|
+
> nock is currently not compatible with Node's experimental native `fetch` implementation. See [#2397](https://github.com/nock/nock/issues/2397)
|
|
14
|
+
|
|
12
15
|
HTTP server mocking and expectations library for Node.js
|
|
13
16
|
|
|
14
17
|
Nock can be used to test modules that perform HTTP requests in isolation.
|
|
@@ -1002,7 +1005,7 @@ const scope = nock('http://example.com')
|
|
|
1002
1005
|
.reply(200, 'Persisting all the way')
|
|
1003
1006
|
```
|
|
1004
1007
|
|
|
1005
|
-
Note that while a persisted scope will always intercept the requests, it is considered "done" after the first interception.
|
|
1008
|
+
Note that while a persisted scope will always intercept the requests, it is considered "done" after the first interception, and they are pushed to the bottom of the stack after consumption.
|
|
1006
1009
|
|
|
1007
1010
|
If you want to stop persisting an individual persisted mock you can call `persist(false)`:
|
|
1008
1011
|
|
package/lib/intercept.js
CHANGED
|
@@ -110,7 +110,7 @@ function addInterceptor(key, interceptor, scope, scopeOptions, host) {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function remove(interceptor) {
|
|
113
|
-
if (
|
|
113
|
+
if (--interceptor.counter > 0) {
|
|
114
114
|
return
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -122,6 +122,12 @@ function remove(interceptor) {
|
|
|
122
122
|
// matching instance. I'm also not sure why we couldn't delete _all_
|
|
123
123
|
// matching instances.
|
|
124
124
|
interceptors.some(function (thisInterceptor, i) {
|
|
125
|
+
if (interceptor.__nock_scope.shouldPersist()) {
|
|
126
|
+
return thisInterceptor === interceptor
|
|
127
|
+
? interceptors.push(interceptors.splice(i, 1)[0])
|
|
128
|
+
: false
|
|
129
|
+
}
|
|
130
|
+
|
|
125
131
|
return thisInterceptor === interceptor ? interceptors.splice(i, 1) : false
|
|
126
132
|
})
|
|
127
133
|
}
|
|
@@ -218,7 +224,11 @@ function removeInterceptor(options) {
|
|
|
218
224
|
) {
|
|
219
225
|
for (let i = 0; i < allInterceptors[baseUrl].interceptors.length; i++) {
|
|
220
226
|
const interceptor = allInterceptors[baseUrl].interceptors[i]
|
|
221
|
-
if (
|
|
227
|
+
if (
|
|
228
|
+
options instanceof Interceptor
|
|
229
|
+
? interceptor === options
|
|
230
|
+
: interceptor._key === key
|
|
231
|
+
) {
|
|
222
232
|
allInterceptors[baseUrl].interceptors.splice(i, 1)
|
|
223
233
|
interceptor.scope.remove(key, interceptor)
|
|
224
234
|
break
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"testing",
|
|
8
8
|
"isolation"
|
|
9
9
|
],
|
|
10
|
-
"version": "13.3.
|
|
10
|
+
"version": "13.3.2",
|
|
11
11
|
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"propagate": "^2.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@definitelytyped/dtslint": "^0.0.
|
|
31
|
+
"@definitelytyped/dtslint": "^0.0.163",
|
|
32
32
|
"@sinonjs/fake-timers": "^10.0.0",
|
|
33
33
|
"assert-rejects": "^1.0.0",
|
|
34
34
|
"chai": "^4.1.2",
|
|
@@ -45,13 +45,13 @@
|
|
|
45
45
|
"mocha": "^9.1.3",
|
|
46
46
|
"npm-run-all": "^4.1.5",
|
|
47
47
|
"nyc": "^15.0.0",
|
|
48
|
-
"prettier": "2.
|
|
48
|
+
"prettier": "2.8.8",
|
|
49
49
|
"proxyquire": "^2.1.0",
|
|
50
50
|
"rimraf": "^3.0.0",
|
|
51
|
-
"semantic-release": "^
|
|
51
|
+
"semantic-release": "^21.0.2",
|
|
52
52
|
"sinon": "^15.0.1",
|
|
53
53
|
"sinon-chai": "^3.7.0",
|
|
54
|
-
"typescript": "^
|
|
54
|
+
"typescript": "^5.0.4"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"format:fix": "prettier --write '**/*.{js,json,md,ts,yml,yaml}'",
|