nock 13.1.0 → 13.1.4
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 +31 -5
- package/lib/intercepted_request_router.js +1 -1
- package/lib/interceptor.js +7 -3
- package/package.json +1 -1
- package/types/index.d.ts +2 -2
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
|
|
|
@@ -1403,6 +1402,14 @@ return nockBack('promisedFixture.json').then(({ nockDone, context }) => {
|
|
|
1403
1402
|
})
|
|
1404
1403
|
```
|
|
1405
1404
|
|
|
1405
|
+
Or, with async/await:
|
|
1406
|
+
|
|
1407
|
+
```js
|
|
1408
|
+
const { nockDone, context } = await nockBack('promisedFixture.json')
|
|
1409
|
+
// your test code
|
|
1410
|
+
nockDone()
|
|
1411
|
+
```
|
|
1412
|
+
|
|
1406
1413
|
#### Options
|
|
1407
1414
|
|
|
1408
1415
|
As an optional second parameter you can pass the following options
|
|
@@ -1566,10 +1573,29 @@ By participating in this project you agree to abide by its terms.
|
|
|
1566
1573
|
Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):
|
|
1567
1574
|
|
|
1568
1575
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
1569
|
-
<!-- prettier-ignore -->
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1576
|
+
<!-- prettier-ignore-start -->
|
|
1577
|
+
<!-- markdownlint-disable -->
|
|
1578
|
+
<table>
|
|
1579
|
+
<tr>
|
|
1580
|
+
<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>
|
|
1581
|
+
<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>
|
|
1582
|
+
<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>
|
|
1583
|
+
<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>
|
|
1584
|
+
<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>
|
|
1585
|
+
<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>
|
|
1586
|
+
<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>
|
|
1587
|
+
</tr>
|
|
1588
|
+
<tr>
|
|
1589
|
+
<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>
|
|
1590
|
+
<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>
|
|
1591
|
+
<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>
|
|
1592
|
+
<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>
|
|
1593
|
+
<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>
|
|
1594
|
+
</tr>
|
|
1595
|
+
</table>
|
|
1596
|
+
|
|
1597
|
+
<!-- markdownlint-restore -->
|
|
1598
|
+
<!-- prettier-ignore-end -->
|
|
1573
1599
|
|
|
1574
1600
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
1575
1601
|
|
package/lib/interceptor.js
CHANGED
|
@@ -442,13 +442,17 @@ module.exports = class Interceptor {
|
|
|
442
442
|
markConsumed() {
|
|
443
443
|
this.interceptionCounter++
|
|
444
444
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
445
|
+
if (
|
|
446
|
+
(this.scope.shouldPersist() || this.counter > 0) &&
|
|
447
|
+
this.interceptionCounter > 1 &&
|
|
448
|
+
this.filePath
|
|
449
|
+
) {
|
|
448
450
|
this.body = fs.createReadStream(this.filePath)
|
|
449
451
|
this.body.pause()
|
|
450
452
|
}
|
|
451
453
|
|
|
454
|
+
remove(this)
|
|
455
|
+
|
|
452
456
|
if (!this.scope.shouldPersist() && this.counter < 1) {
|
|
453
457
|
this.scope.remove(this._key, this)
|
|
454
458
|
}
|
package/package.json
CHANGED
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
|
}
|
|
@@ -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
|