Skip to content

Commit

Permalink
Add type definition for lastResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe7 authored and wheresrhys committed Oct 2, 2020
1 parent 9a5ca71 commit d5dbe76
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,28 @@ declare namespace fetchMock {
options?: InspectionOptions,
): MockOptions | undefined;

/**
* Returns the options for the call to fetch matching the given filter.
* This is an experimental feature, very difficult to implement well given
* fetch’s very private treatment of response bodies.
* When doing all the following:
- using node-fetch
- responding with a real network response (using spy() or fallbackToNetwork)
- using `fetchMock.LastResponse()`
- awaiting the body content
… the response will hang unless your source code also awaits the response body.
This is an unavoidable consequence of the nodejs implementation of streams.
* @param [filter] Allows filtering of calls to fetch based on various
* criteria
* @param [options] Either an object compatible with the mocking api or
* a string specifying a http method to filter by. This will be used to
* filter the list of calls further.
*/
lastResponse(
filter?: InspectionFilter,
options?: InspectionOptions,
): Response | undefined;

config: {
/**
* Convert objects into JSON before delivering as stub responses.
Expand Down

0 comments on commit d5dbe76

Please sign in to comment.