marchaos / jest-mock-extended

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

Capture arguments passed to method on mocked object #132

Open gusgorman2 opened 2 months ago

gusgorman2 commented 2 months ago

Hi,

Is there any way to capture arguments passed to a method on a mocked object.

For example, if we have:

export abstract class StatusDao {
  abstract getWhere(codes: string[]): Promise<Status>
}

and then:

const statusDao: MockProxy<StatusDao> = mock<StatusDao>()

would there any way to capture any arguments passed to getWhere ?

I know I can use expect(statusDao.getWhere).toHaveBeenCalledWith() but this doesn't always quite do what i want