vitest-mock-extended
vitest-mock-extended copied to clipboard
Mocking an async function call does not return mock value.
it('able to create user with prisma', async () => {
const db: DeepMockProxy<PrismaClient> = mockDeep<PrismaClient>()
// I do assign mock value for extension but it doesn't seem to return user
db.user.create.calledWith({ data: user }).mockResolvedValue(user)
const result = await db.user.create({ data: user })
console.log('AAAA result', result ?? 'Nothing returned')
expect(result).toBe(user)
})
Could you provide a minimal repo so I can check it out and debug?
Sorry I could not provide a minimal repo at this moment but the root issue happen with calledWith({ data: user })
Without trigger calledWith({ data: user }) the mock function work pretty well.
For me to debug this a minimal repo would be very appreciated.
@eratio08 Sure, I will do it by this weekend. Thank you for notice