Skip to content

Commit

Permalink
Updated documentation. (#96)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruben Duiveman <[email protected]>
  • Loading branch information
rubenduiveman and Ruben Duiveman authored Mar 16, 2023
1 parent 45e90f7 commit 63d4656
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ However, if you look at the [source code](https://github.com/knee-cola/jest-mock
* [axios.getReqByRegex](#axiosgetreqbyregexopts)
* [axios.lastPromiseGet](#axioslastpromiseget)
* [axios.reset](#axiosreset)
* [axios.useRequestHandler](#axiosuserequesthandler)
* [Additional examples](#additional-examples)
* [Values returned by `lastReqGet` and `lastPromiseGet` methods](#values-returned-by-lastreqget-and-lastpromiseget-methods)
* [Resolving requests out of order](#resolving-requests-out-of-order)
Expand Down Expand Up @@ -311,6 +312,15 @@ The promise object returned by this function corresponds to the one returned by
## axios.reset()
`reset` method clears state of the Axios mock to initial values. It should be called after each test, so that we can start fresh with our next test (i.e. from `afterEach` method).

## axios.useRequestHandler()
`useRequestHandler` method allows setting a request handler that gets invoked every time a new request comes in. The handler method is invoked with the new request item.

```ts
mockAxios.useRequestHandler((req: AxiosMockQueueItem) => {
// do something with req...
}))
```

# Additional examples
Since AxiosMock is relatively simple, most of its functionality was covered in [basic example](#basic-example) at the beginning of this document. In this section we'll explore features not covered by that initial example.

Expand Down

0 comments on commit 63d4656

Please sign in to comment.