Skip to content

Commit

Permalink
Merge pull request #23 from skovhus/typescript-types
Browse files Browse the repository at this point in the history
Add TypeScript type definition
  • Loading branch information
wheresrhys authored Nov 21, 2020
2 parents bf3bc05 + 052018c commit c35a560
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { InspectionFilter, InspectionOptions, FetchMockStatic, MockCall, FetchMockSandbox } from 'fetch-mock';

declare global {
namespace jest {
interface Matchers<R> {
toHaveFetched(filter?: InspectionFilter, options?: InspectionOptions): R;
toHaveLastFetched(filter?: InspectionFilter, options?: InspectionOptions): R;
toHaveNthFetched(n: number, filter?: InspectionFilter, options?: InspectionOptions): R;
toHaveFetchedTimes(times: number, filter?: InspectionFilter, options?: InspectionOptions): R;
toBeDone(filter?: InspectionFilter): R;
}
}
}


interface FetchMockJest {
// Reset the call history
mockClear(): void;
// Remove all configured mocks
mockReset(): void;
// Enable sandbox mode
sandbox(): jest.MockInstance<Response, MockCall> & FetchMockSandbox;
}

declare const fetchMockJest: FetchMockJest & jest.MockInstance<Response, MockCall> & FetchMockStatic

export = fetchMockJest;
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Jest wrapper for fetch-mock, a comprehensive stub for fetch",
"main": "server.js",
"browser": "browser.js",
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down

0 comments on commit c35a560

Please sign in to comment.