jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
883 stars 116 forks source link

jest.mock Property is not visible in the TypeScript headers. #109

Open eiswind opened 5 years ago

eiswind commented 5 years ago

In the examples I can see things like:

expect(fetch.mock.calls.length).toEqual(1) expect(fetch.mock.calls[0][0]).toEqual('https://google.com')

unfortunately this is not defined in the typescript files.

eiswind commented 5 years ago

I can see that its defined on MockInstance, but I fail to make it accessible. Is there any trick that it needs to be imported?

butchyyyy commented 5 years ago

I think the problem is the FetchMock is defined as:

export interface FetchMock extends jest.MockInstance<any> {

But the jest type has two generics:

interface MockInstance<T, Y extends any[]> {

Changing the FetchMock definition to:

export interface FetchMock extends jest.MockInstance<any, any> {

fixes the issue

This is a duplicate to #108