У меня есть этот сервис:
@Service()
export class HostelService {
private readonly booking: Booking;
constructor(bookingService: BookingService) {
this.booking = bookingService.getBooking();
}
..
}
и на моем шутке
const booking = createMockInstance(Booking);
const bookingService: BookingService = ({
getBooking: () => booking
} as unknown) as BookingService;
const bookingService = createMockInstance(BookingService);
const somethingSpy = jest.spyOn(booking, 'print');
expect(somethingSpy).toHaveBeenCalled();
метод print вызывается, но тест не пройден
Expected number of calls: >= 1
Received number of calls: 0