How to fix TypeError is not a function (testing promises with Jest)
It looks like the reason why you're getting this error has to do with the data you're mocking through Jest.
Try using jest.fn()
to mock your getIdToken
as a function, rather than a string:
const mockGetIdToken = jest.fn(() => 'abc123');jest.mock('services/firebase', () => new Promise(resolve => resolve({ signInWithEmailAndPassword: () => Promise.resolve({ getIdToken: mockGetIdToken }), getIdToken: mockGetIdToken, signOut: () => jest.fn()})));describe('login actions', () => { let store; beforeEach(() => { store = mockStore({}); }); it('signIn should call firebase', () => { const user = { email: 'first.last@yum.com', password: 'abd123' }; return store.dispatch(signIn(user.email, user.password)) .then(() => { console.log('TEST signIn SUCCESS'); expect(mockSignIn).toHaveBeenCalled(); expect(store.getActions()).toEqual({ type: USER_ON_LOGGED_IN }); }) .catch((err) => { console.log('TEST signIn ERROR =>', err); }); });