diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index c9b1737a47..02e360026e 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -1,4 +1,5 @@ import * as fetchMock from "fetch-mock"; +import { MockResponse } from "fetch-mock"; fetchMock.mock("http://test.com", 200); fetchMock.mock(/test\.com/, 200); @@ -65,3 +66,6 @@ const myMatcher: fetchMock.MockMatcherFunction = ( url: string, opts: fetchMock.MockRequest ) => true; + +fetchMock.flush().then(resolved => resolved.forEach(console.log)); +fetchMock.flush().catch(r => r); diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index f1c109bb53..4b89b1decd 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -1,6 +1,9 @@ -// Type definitions for fetch-mock 5.8 +// Type definitions for fetch-mock 5.12 // Project: https://github.com/wheresrhys/fetch-mock -// Definitions by: Alexey Svetliakov , Tamir Duberstein , Risto Keravuori +// Definitions by: Alexey Svetliakov +// Tamir Duberstein +// Risto Keravuori +// Chris Sinclair // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -333,6 +336,12 @@ declare namespace fetchMock { */ reset(): this; + /** + * Returns a promise that resolves once all fetches handled by fetch-mock + * have resolved. + */ + flush(): Promise; + /** * Returns all calls to fetch, grouped by whether fetch-mock matched * them or not.