Skip to content

Commit

Permalink
docs(readme): update docs for repeating usage (#2169)
Browse files Browse the repository at this point in the history
  • Loading branch information
taozi0818 committed Mar 9, 2021
1 parent bfbbbb7 commit 2134a41
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,14 +640,24 @@ const scope = nock('http://my.server.com:8081')

You are able to specify the number of times to repeat the same response.

**NOTE:** When request times is more than the number you specified, you will get an error before cleaning this interceptor.

```js
nock('http://zombo.com').get('/').times(4).reply(200, 'Ok')

http.get('http://zombo.com/') // respond body "Ok"
http.get('http://zombo.com/') // respond body "Ok"
http.get('http://zombo.com/') // respond body "Ok"
http.get('http://zombo.com/') // respond body "Ok"
http.get('http://zombo.com/') // respond with zombo.com result

// This code will get an error with message:
// Nock: No match for request
http.get('http://zombo.com/')

// clean your interceptor
nock.cleanAll()

http.get('http://zombo.com/') // real respond with zombo.com result
```

Sugar syntax
Expand Down

0 comments on commit 2134a41

Please sign in to comment.