Update checked-in dependencies
This commit is contained in:
parent
7fdbca3ba3
commit
357e0ceaa9
360 changed files with 25673 additions and 917 deletions
57
node_modules/nock/README.md
generated
vendored
57
node_modules/nock/README.md
generated
vendored
|
|
@ -1,21 +1,11 @@
|
|||
# Nock
|
||||
|
||||
[][npmjs]
|
||||
[][build]
|
||||

|
||||
[](#backers)
|
||||
[](#sponsors)
|
||||
|
||||
[npmjs]: https://www.npmjs.com/package/nock
|
||||
[build]: https://travis-ci.org/nock/nock
|
||||
|
||||
> **Notice**
|
||||
>
|
||||
> We have introduced experimental support for fetch. Please share your feedback with us. You can install it by:
|
||||
>
|
||||
> ```
|
||||
> npm install --save-dev nock@beta
|
||||
> ```
|
||||
|
||||
HTTP server mocking and expectations library for Node.js
|
||||
|
||||
|
|
@ -694,46 +684,17 @@ You are able to specify the number of milliseconds that your reply should be del
|
|||
```js
|
||||
nock('http://my.server.com')
|
||||
.get('/')
|
||||
.delay(2000) // 2 seconds delay will be applied to the response header.
|
||||
.delay(2000) // 2 seconds delay will be applied to the response body.
|
||||
.reply(200, '<html></html>')
|
||||
```
|
||||
|
||||
`delay(1000)` is an alias for `delayConnection(1000).delayBody(0)`
|
||||
`delay({ head: 1000, body: 2000 })` is an alias for `delayConnection(1000).delayBody(2000)`
|
||||
Both of which are covered in detail below.
|
||||
|
||||
#### Delay the connection
|
||||
|
||||
You are able to specify the number of milliseconds that your connection should be idle before it starts to receive the response.
|
||||
|
||||
To simulate a socket timeout, provide a larger value than the timeout setting on the request.
|
||||
|
||||
```js
|
||||
nock('http://my.server.com')
|
||||
.get('/')
|
||||
.delayConnection(2000) // 2 seconds
|
||||
.reply(200, '<html></html>')
|
||||
|
||||
req = http.request('http://my.server.com', { timeout: 1000 })
|
||||
```
|
||||
|
||||
Nock emits timeout events almost immediately by comparing the requested connection delay to the timeout parameter passed to `http.request()` or `http.ClientRequest#setTimeout()`.
|
||||
This allows you to test timeouts without using fake timers or slowing down your tests.
|
||||
If the client chooses to _not_ take an action (e.g. abort the request), the request and response will continue on as normal, after real clock time has passed.
|
||||
|
||||
##### Technical Details
|
||||
|
||||
Following the `'finish'` event being emitted by `ClientRequest`, Nock will wait for the next event loop iteration before checking if the request has been aborted.
|
||||
At this point, any connection delay value is compared against any request timeout setting and a [`'timeout'`](https://nodejs.org/api/http.html#http_event_timeout) is emitted when appropriate from the socket and the request objects.
|
||||
A Node timeout timer is then registered with any connection delay value to delay real time before checking again if the request has been aborted and the [`'response'`](http://nodejs.org/api/http.html#http_event_response) is emitted by the request.
|
||||
|
||||
A similar method, `.socketDelay()` was removed in version 13. It was thought that having two methods so subtlety similar was confusing.
|
||||
The discussion can be found at https://github.com/nock/nock/pull/1974.
|
||||
The `delayConnection` method’s behavior of emitting quick timeout events when the connection delay exceeds the request timeout is now deprecated. Please use the `delay` function instead.
|
||||
|
||||
#### Delay the response body
|
||||
|
||||
You are able to specify the number of milliseconds that the response body should be delayed.
|
||||
This is the time between the headers being received and the body starting to be received.
|
||||
The `delayBody` is now deprecated. Please use the `delay` function instead.
|
||||
|
||||
```js
|
||||
nock('http://my.server.com')
|
||||
|
|
@ -1643,10 +1604,10 @@ It does this by manipulating the modules cache of Node in a way that conflicts w
|
|||
|
||||
## Debugging
|
||||
|
||||
Nock uses [`debug`](https://github.com/visionmedia/debug), so just run with environmental variable `DEBUG` set to `nock.*`.
|
||||
Nock uses node internals [`debuglog`](https://nodejs.org/api/util.html#utildebuglogsection-callbackg), so just run with environmental variable `NODE_DEBUG` set to `nock:*`.
|
||||
|
||||
```console
|
||||
user@local$ DEBUG=nock.* node my_test.js
|
||||
user@local$ NODE_DEBUG=nock:* node my_test.js
|
||||
```
|
||||
|
||||
Each step in the matching process is logged this way and can be useful when determining why a request was not intercepted by Nock.
|
||||
|
|
@ -1660,11 +1621,11 @@ await got('http://example.com/?foo=bar&baz=foz')
|
|||
```
|
||||
|
||||
```console
|
||||
user@local$ DEBUG=nock.scope:example.com node my_test.js
|
||||
user@local$ DEBUG=nock:scope:example.com node my_test.js
|
||||
...
|
||||
nock.scope:example.com Interceptor queries: {"foo":"bar"} +1ms
|
||||
nock.scope:example.com Request queries: {"foo":"bar","baz":"foz"} +0ms
|
||||
nock.scope:example.com query matching failed +0ms
|
||||
NOCK:SCOPE:EXAMPLE.COM 103514: Interceptor queries: {"foo":"bar"}
|
||||
NOCK:SCOPE:EXAMPLE.COM 103514: Request queries: {"foo":"bar","baz":"foz"}
|
||||
NOCK:SCOPE:EXAMPLE.COM 103514: query matching failed
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue