marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
839 stars 57 forks source link

Required to use calledWith when using TypeScript #114

Closed dan2kx closed 4 weeks ago

dan2kx commented 1 year ago

When using typescript i am required to use calledWith on a deep mocked function instead of not providing this, or i have to ts-ignore it, if there is no way to avoid this, can calledWIth be called without passing a matcher as the default if i want to mock in all cases?

Works:

// @ts-ignore
prismaMock.model.create.mockResolvedValue()

Should work without ts-ignore?

prismaMock.model.create.mockResolvedValue()

Or

prismaMock.model.create.calledWith().mockResolvedValue()

instead of

prismaMock.model.create.calledWith(any()).mockResolvedValue()
dan2kx commented 1 year ago

it seems this problem goes away when adding the @types/jest@27.5.0 so i think issue #115 is the problem here, i think maybe the types need to be updated for the package

theMogget commented 1 year ago

it seems this problem goes away when adding the @types/jest@27.5.0 so i think issue #115 is the problem here, i think maybe the types need to be updated for the package

This worked for me, thank you so much!!