mardi 11 août 2020

Testing a redux function

I am testing a function like this

export default (middlewares) => {
    return createStore(rootReducer, applyMiddleware(...middlewares));
};

For this I wrote a mock test using jest

import { createStore } from 'redux';
import createGlobalStore from '../store';

jest.mock('redux');

describe('Store test', () => {
    it('testing create global store', () => {
        const mockTestValue = 1;
        createStore.mockResolvedValue(mockTestValue);
        expect(createGlobalStore([])).toBe(mockTestValue);
    });
});

But my code is failing.

expect(received).toBe(expected) // Object.is equality

    Expected: 1
    Received: {}

I am not sure if I have written correct test case. Could anybody help me correcting this or writing this test case better way?

Aucun commentaire:

Enregistrer un commentaire