Sometimes, we want to fix ‘property mock does not exist on type’ error with Jest and TypeScript.
In this article, we’ll look at how to fix ‘property mock does not exist on type’ error with Jest and TypeScript.
How to fix ‘property mock does not exist on type’ error with Jest and TypeScript?
To fix ‘property mock does not exist on type’ error with Jest and TypeScript, we can cast the variable with the error to the jest.MockedFunction<typeof addListener>
type.
For instance, we write
const addListenerMock = addListener as jest.MockedFunction<typeof addListener>;
to cast the type with as
.
Conclusion
To fix ‘property mock does not exist on type’ error with Jest and TypeScript, we can cast the variable with the error to the jest.MockedFunction<typeof addListener>
type.