nock 13.0.10 → 13.1.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 CHANGED
@@ -3,7 +3,6 @@
3
3
  [![npm](https://img.shields.io/npm/v/nock.svg)][npmjs]
4
4
  [![Build Status](https://travis-ci.org/nock/nock.svg)][build]
5
5
  ![Coverage Status](http://img.shields.io/badge/coverage-100%25-brightgreen.svg)
6
- ![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=nock/nock)
7
6
  [![Backers on Open Collective](https://opencollective.com/nock/backers/badge.svg)](#backers)
8
7
  [![Sponsors on Open Collective](https://opencollective.com/nock/sponsors/badge.svg)](#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
- http.get('http://zombo.com/') // respond with zombo.com result
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
@@ -1556,10 +1565,29 @@ By participating in this project you agree to abide by its terms.
1556
1565
  Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
1557
1566
 
1558
1567
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
1559
- <!-- prettier-ignore -->
1560
- | [<img src="https://avatars1.githubusercontent.com/u/47910?v=4" width="100px;" alt="Pedro Teixeira"/><br /><sub><b>Pedro Teixeira</b></sub>](http://pgte.me)<br />[💻](https://github.com/nock/nock/commits?author=pgte "Code") [🚧](#maintenance-pgte "Maintenance") | [<img src="https://avatars3.githubusercontent.com/u/10771967?v=4" width="100px;" alt="n30n0v"/><br /><sub><b>n30n0v</b></sub>](https://github.com/n30n0v)<br />[💻](https://github.com/nock/nock/commits?author=n30n0v "Code") | [<img src="https://avatars3.githubusercontent.com/u/910753?v=4" width="100px;" alt="Richard Littauer"/><br /><sub><b>Richard Littauer</b></sub>](https://burntfen.com)<br />[🚧](#maintenance-RichardLitt "Maintenance") [💻](https://github.com/nock/nock/commits?author=RichardLitt "Code") [📝](#blog-RichardLitt "Blogposts") | [<img src="https://avatars1.githubusercontent.com/u/3731165?v=4" width="100px;" alt="Ian Walker-Sperber"/><br /><sub><b>Ian Walker-Sperber</b></sub>](http://ianwsperber.com)<br />[💻](https://github.com/nock/nock/commits?author=ianwsperber "Code") | [<img src="https://avatars2.githubusercontent.com/u/1505203?v=4" width="100px;" alt="Ivan Erceg"/><br /><sub><b>Ivan Erceg</b></sub>](http://ilovacha.com)<br />[💻](https://github.com/nock/nock/commits?author=ierceg "Code") [🚧](#maintenance-ierceg "Maintenance") | [<img src="https://avatars2.githubusercontent.com/u/1487036?v=4" width="100px;" alt="Paul Melnikow"/><br /><sub><b>Paul Melnikow</b></sub>](https://twitter.com/paulmelnikow)<br />[💻](https://github.com/nock/nock/commits?author=paulmelnikow "Code") [🚧](#maintenance-paulmelnikow "Maintenance") | [<img src="https://avatars3.githubusercontent.com/u/39992?v=4" width="100px;" alt="Gregor Martynus"/><br /><sub><b>Gregor Martynus</b></sub>](https://twitter.com/gr2m)<br />[💻](https://github.com/nock/nock/commits?author=gr2m "Code") [🚧](#maintenance-gr2m "Maintenance") [💼](#business-gr2m "Business development") [💵](#financial-gr2m "Financial") [📝](#blog-gr2m "Blogposts") |
1561
- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
1562
- | [<img src="https://avatars1.githubusercontent.com/u/6701030?v=4" width="100px;" alt="Hutson Betts"/><br /><sub><b>Hutson Betts</b></sub>](https://gitlab.com/hutson)<br />[💵](#financial-hutson "Financial") | [<img src="https://avatars2.githubusercontent.com/u/6105119?v=4" width="100px;" alt="Jonas Lilja"/><br /><sub><b>Jonas Lilja</b></sub>](http://lilja.io)<br />[💵](#financial-jlilja "Financial") [💻](https://github.com/nock/nock/commits?author=jlilja "Code") | [<img src="https://avatars0.githubusercontent.com/u/4446950?v=4" width="100px;" alt="Benjamin Ki"/><br /><sub><b>Benjamin Ki</b></sub>](https://github.com/benrki)<br />[💵](#financial-benrki "Financial") | [<img src="https://avatars2.githubusercontent.com/u/3250463?v=4" width="100px;" alt="Chad Fawcett"/><br /><sub><b>Chad Fawcett</b></sub>](http://chadf.ca)<br />[💵](#financial-chadfawcett "Financial") |
1568
+ <!-- prettier-ignore-start -->
1569
+ <!-- markdownlint-disable -->
1570
+ <table>
1571
+ <tr>
1572
+ <td align="center"><a href="http://pgte.me"><img src="https://avatars1.githubusercontent.com/u/47910?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Pedro Teixeira</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=pgte" title="Code">💻</a> <a href="#maintenance-pgte" title="Maintenance">🚧</a></td>
1573
+ <td align="center"><a href="https://github.com/n30n0v"><img src="https://avatars3.githubusercontent.com/u/10771967?v=4?s=100" width="100px;" alt=""/><br /><sub><b>n30n0v</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=n30n0v" title="Code">💻</a></td>
1574
+ <td align="center"><a href="https://burntfen.com"><img src="https://avatars3.githubusercontent.com/u/910753?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Richard Littauer</b></sub></a><br /><a href="#maintenance-RichardLitt" title="Maintenance">🚧</a> <a href="https://github.com/nock/nock/commits?author=RichardLitt" title="Code">💻</a> <a href="#blog-RichardLitt" title="Blogposts">📝</a></td>
1575
+ <td align="center"><a href="http://ianwsperber.com"><img src="https://avatars1.githubusercontent.com/u/3731165?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ian Walker-Sperber</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=ianwsperber" title="Code">💻</a></td>
1576
+ <td align="center"><a href="http://ilovacha.com"><img src="https://avatars2.githubusercontent.com/u/1505203?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Erceg</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=ierceg" title="Code">💻</a> <a href="#maintenance-ierceg" title="Maintenance">🚧</a></td>
1577
+ <td align="center"><a href="https://twitter.com/paulmelnikow"><img src="https://avatars2.githubusercontent.com/u/1487036?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Melnikow</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=paulmelnikow" title="Code">💻</a> <a href="#maintenance-paulmelnikow" title="Maintenance">🚧</a></td>
1578
+ <td align="center"><a href="https://twitter.com/gr2m"><img src="https://avatars3.githubusercontent.com/u/39992?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gregor Martynus</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=gr2m" title="Code">💻</a> <a href="#maintenance-gr2m" title="Maintenance">🚧</a> <a href="#business-gr2m" title="Business development">💼</a> <a href="#financial-gr2m" title="Financial">💵</a> <a href="#blog-gr2m" title="Blogposts">📝</a></td>
1579
+ </tr>
1580
+ <tr>
1581
+ <td align="center"><a href="https://gitlab.com/hutson"><img src="https://avatars1.githubusercontent.com/u/6701030?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hutson Betts</b></sub></a><br /><a href="#financial-hutson" title="Financial">💵</a></td>
1582
+ <td align="center"><a href="http://lilja.io"><img src="https://avatars2.githubusercontent.com/u/6105119?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonas Lilja</b></sub></a><br /><a href="#financial-jlilja" title="Financial">💵</a> <a href="https://github.com/nock/nock/commits?author=jlilja" title="Code">💻</a></td>
1583
+ <td align="center"><a href="https://github.com/benrki"><img src="https://avatars0.githubusercontent.com/u/4446950?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Benjamin Ki</b></sub></a><br /><a href="#financial-benrki" title="Financial">💵</a></td>
1584
+ <td align="center"><a href="http://chadf.ca"><img src="https://avatars2.githubusercontent.com/u/3250463?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chad Fawcett</b></sub></a><br /><a href="#financial-chadfawcett" title="Financial">💵</a></td>
1585
+ <td align="center"><a href="http://www.laurencemyers.com.au"><img src="https://avatars.githubusercontent.com/u/6336048?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Laurence Dougal Myers</b></sub></a><br /><a href="https://github.com/nock/nock/commits?author=laurence-myers" title="Code">💻</a></td>
1586
+ </tr>
1587
+ </table>
1588
+
1589
+ <!-- markdownlint-restore -->
1590
+ <!-- prettier-ignore-end -->
1563
1591
 
1564
1592
  <!-- ALL-CONTRIBUTORS-LIST:END -->
1565
1593
 
@@ -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/socket.js CHANGED
@@ -92,6 +92,7 @@ module.exports = class Socket extends EventEmitter {
92
92
  debug('socket destroy')
93
93
  this.destroyed = true
94
94
  this.readable = this.writable = false
95
+ this.readableEnded = this.writableFinished = true
95
96
 
96
97
  process.nextTick(() => {
97
98
  if (err) {
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "testing",
8
8
  "isolation"
9
9
  ],
10
- "version": "13.0.10",
10
+ "version": "13.1.2",
11
11
  "author": "Pedro Teixeira <pedro.teixeira@gmail.com>",
12
12
  "repository": {
13
13
  "type": "git",
@@ -28,14 +28,14 @@
28
28
  "propagate": "^2.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@sinonjs/fake-timers": "^6.0.0",
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": "^6.0.0",
38
- "eslint-config-standard": "^14.0.0",
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",
@@ -48,12 +48,10 @@
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": "^9.0.0",
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 Array<DataMatcher> {}
55
+ interface DataMatcherArray extends ReadonlyArray<DataMatcher> {}
56
56
  interface DataMatcherMap {
57
57
  [key: string]: DataMatcher
58
58
  }
@@ -198,7 +198,7 @@ declare namespace nock {
198
198
  once(): this
199
199
  twice(): this
200
200
  thrice(): this
201
- optionally(): this
201
+ optionally(flag?: boolean): this
202
202
 
203
203
  delay(opts: number | { head?: number; body?: number }): this
204
204
  delayBody(timeMs: number): this