I have a controller that uses NestJS built-in Logger via dependency injection in constructor of the controller:
constructor(private readonly logger: Logger)
I want to be able to mock it in my Jest tests to see which methods and with what arguments are being called during logging. I tried this syntax:
providers[{
provide: Logger,
useValue: {
log: jest.fn(),
}
}]
In that case this line:
expect(Logger).toHaveBeenCalledTimes(1);
Returns: Matcher error: received value must be a mock or spy function
Any help will be highly appreciated!