nock 13.0.9 → 13.1.1
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 +11 -2
- package/lib/interceptor.js +2 -1
- package/lib/recorder.js +0 -2
- package/lib/socket.js +1 -0
- package/package.json +6 -8
- package/types/index.d.ts +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
[][npmjs]
|
|
4
4
|
[][build]
|
|
5
5
|

|
|
6
|
-

|
|
7
6
|
[](#backers)
|
|
8
7
|
[](#sponsors)
|
|
9
8
|
|
|
@@ -640,6 +639,8 @@ const scope = nock('http://my.server.com:8081')
|
|
|
640
639
|
|
|
641
640
|
You are able to specify the number of times to repeat the same response.
|
|
642
641
|
|
|
642
|
+
**NOTE:** When request times is more than the number you specified, you will get an error before cleaning this interceptor.
|
|
643
|
+
|
|
643
644
|
```js
|
|
644
645
|
nock('http://zombo.com').get('/').times(4).reply(200, 'Ok')
|
|
645
646
|
|
|
@@ -647,7 +648,15 @@ http.get('http://zombo.com/') // respond body "Ok"
|
|
|
647
648
|
http.get('http://zombo.com/') // respond body "Ok"
|
|
648
649
|
http.get('http://zombo.com/') // respond body "Ok"
|
|
649
650
|
http.get('http://zombo.com/') // respond body "Ok"
|
|
650
|
-
|
|
651
|
+
|
|
652
|
+
// This code will get an error with message:
|
|
653
|
+
// Nock: No match for request
|
|
654
|
+
http.get('http://zombo.com/')
|
|
655
|
+
|
|
656
|
+
// clean your interceptor
|
|
657
|
+
nock.cleanAll()
|
|
658
|
+
|
|
659
|
+
http.get('http://zombo.com/') // real respond with zombo.com result
|
|
651
660
|
```
|
|
652
661
|
|
|
653
662
|
Sugar syntax
|
package/lib/interceptor.js
CHANGED
|
@@ -32,8 +32,9 @@ module.exports = class Interceptor {
|
|
|
32
32
|
// When enabled filteringScope ignores the passed URL entirely so we skip validation.
|
|
33
33
|
|
|
34
34
|
if (
|
|
35
|
-
!scope.scopeOptions.filteringScope &&
|
|
36
35
|
uriIsStr &&
|
|
36
|
+
!scope.scopeOptions.filteringScope &&
|
|
37
|
+
!scope.basePathname &&
|
|
37
38
|
!uri.startsWith('/') &&
|
|
38
39
|
!uri.startsWith('*')
|
|
39
40
|
) {
|
package/lib/recorder.js
CHANGED
package/lib/socket.js
CHANGED
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"testing",
|
|
8
8
|
"isolation"
|
|
9
9
|
],
|
|
10
|
-
"version": "13.
|
|
10
|
+
"version": "13.1.1",
|
|
11
11
|
"author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -28,32 +28,30 @@
|
|
|
28
28
|
"propagate": "^2.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@sinonjs/fake-timers": "^
|
|
31
|
+
"@sinonjs/fake-timers": "^7.0.2",
|
|
32
32
|
"assert-rejects": "^1.0.0",
|
|
33
33
|
"chai": "^4.1.2",
|
|
34
34
|
"dirty-chai": "^2.0.1",
|
|
35
35
|
"dtslint": "^4.0.4",
|
|
36
36
|
"eslint": "^7.3.1",
|
|
37
|
-
"eslint-config-prettier": "^
|
|
38
|
-
"eslint-config-standard": "^
|
|
37
|
+
"eslint-config-prettier": "^8.1.0",
|
|
38
|
+
"eslint-config-standard": "^16.0.2",
|
|
39
39
|
"eslint-plugin-import": "^2.16.0",
|
|
40
40
|
"eslint-plugin-mocha": "^8.0.0",
|
|
41
41
|
"eslint-plugin-node": "^11.0.0",
|
|
42
42
|
"eslint-plugin-promise": "^4.1.1",
|
|
43
43
|
"eslint-plugin-standard": "^5.0.0",
|
|
44
|
-
"form-data": "^
|
|
44
|
+
"form-data": "^4.0.0",
|
|
45
45
|
"got": "^11.3.0",
|
|
46
46
|
"mocha": "^8.0.1",
|
|
47
47
|
"npm-run-all": "^4.1.5",
|
|
48
48
|
"nyc": "^15.0.0",
|
|
49
49
|
"prettier": "2.2.1",
|
|
50
50
|
"proxyquire": "^2.1.0",
|
|
51
|
-
"request": "^2.83.0",
|
|
52
51
|
"rimraf": "^3.0.0",
|
|
53
52
|
"semantic-release": "^17.0.2",
|
|
54
|
-
"sinon": "^
|
|
53
|
+
"sinon": "^10.0.0",
|
|
55
54
|
"sinon-chai": "^3.3.0",
|
|
56
|
-
"superagent": "^6.1.0",
|
|
57
55
|
"typescript": "^4.2.2"
|
|
58
56
|
},
|
|
59
57
|
"scripts": {
|
package/types/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare namespace nock {
|
|
|
52
52
|
| RegExp
|
|
53
53
|
| DataMatcherArray
|
|
54
54
|
| DataMatcherMap
|
|
55
|
-
interface DataMatcherArray extends
|
|
55
|
+
interface DataMatcherArray extends ReadonlyArray<DataMatcher> {}
|
|
56
56
|
interface DataMatcherMap {
|
|
57
57
|
[key: string]: DataMatcher
|
|
58
58
|
}
|