mycroft16
mycroft16

Reputation: 825

Jest test failing with two errors

This is the test I'm trying to run:

it('should return Notification Groups', (done) => {
  fetchAppNotifications('123', 'abc').subscribe((response) => {
    try {
      expect(response).toEqual(MOCK_FETCH_APP_NOTIFICATIONS_RESPONSE);
      done();
    } catch (error) {
      done.fail(error);
    }
  });
});

I get the following errors back:

  1. Timeout - Async callback was not invoked within the 5000 ms timeout specified
  2. Expected at least one assertion to be called but received none.

This is the function being tested:

export function fetchAppNotifications(practiceId: string, clinicId: string): Observable<INotificationGroups> {
  const start = format(startOfDay(new Date()), 'M/d/yyyy');
  const end = format(endOfDay(new Date()), 'M/d/yyyy');
  return GET<INotificationGroups>(Api.Portal, 'AppNotifications/Get', {
    params: {
      practiceId,
      start,
      end,
      type: '0',
      status: '0',
      clinicId,
    },
  });
}

I've tried googling these errors but I'm not getting any help from them. There are other tests, identical to this one for other functions that run fine without either of those errors. I'm at a complete loss as to what would be causing this here, but not on other tests. Using Jest 26.6.3

Upvotes: 0

Views: 475

Answers (1)

VS1928
VS1928

Reputation: 67

make it an async call fetchAppNotifications('123', 'abc').subscribe(async(response) => { }

Upvotes: 0

Related Questions