jest-fetch-mock icon indicating copy to clipboard operation
jest-fetch-mock copied to clipboard

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

Open eiswind opened this issue 6 years ago • 2 comments

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 avatar Feb 11 '19 17:02 eiswind

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?

eiswind avatar Feb 11 '19 17:02 eiswind

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

butchyyyy avatar Feb 15 '19 11:02 butchyyyy