Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property 'mock' does not exist on type 'FetchMock' #248

Open
snebjorn opened this issue Aug 17, 2023 · 1 comment
Open

Property 'mock' does not exist on type 'FetchMock' #248

snebjorn opened this issue Aug 17, 2023 · 1 comment

Comments

@snebjorn
Copy link

I just encountered this error.

import fetchMock from 'jest-fetch-mock';

fetchMock.mock...
// -------^
// Property 'mock' does not exist on type 'FetchMock'

The issue is this
image

I'm using @jest/globals instead of @types/jest in my setup.
The other packages I use all removed @types/jest so now it's no longer in the node_modules folder.
jest-fetch-mock doesn't list @types/jest as a dependency.

Any chance for a fix so jest-fetch-mock works out of the box?
I see two solutions.

  1. Add @types/jest to the dependencies.
  2. Switch to @jest/globals and add it to the dependencies.

The latter seems more futureproof.

@timhooker
Copy link

Nice solution here. Just adding one of the above type packages to my dependencies fixes a very confusing problem where typescript was red but the tests were green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants