Jest mock not resolving to each injected value

A new getUserByEmail spy is created on each auth call, it isn’t called more than once.

Instead, it should be:

const mockGetUserByEmail = jest.fn();
jest.mock('firebase-admin', () => ({
  auth: () => ({
    getUserByEmail: mockGetUserByEmail
  })
}));

...
mockGetUserByEmail
  .mockResolvedValueOnce({ uid: 'foo-bar' })
  .mockResolvedValueOnce(null);
const responsePromises = responseOptions.map(() => send.myCloudFn(email));
...

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top