I am currently doing unit tests on with Jest on one of my react services (using redux-saga). These services call API, selectors and actions which are outside from the other API, selectors, and actions specific to this service.
So to mock these outside API, selectors, and actions, I used jest to mock them in my test file like this:
// API mock example
jest.mock('../otherFeatureService/api'), () => {
return { myApi: jest.fn() };
}
// reducer mock example
jest.mock('../otherFeatureService/reducer'), () => {
return { isConnected: (fake) => jest.fn(fake) };
}
// API action example
jest.mock('../otherFeatureService/actions'), () => {
return { myAction: () => jest.fn() };
}
Everything works fine in my tests, except the mock actions. However, I got the below message when I tried to compare my expected result with the one I got for my mock actions:
expect(received).toEqual(expected)
Expected value to equal:
{"@@redux-saga/IO": true, "PUT": {"action": [Function mockConstructor], "channel": null}}
Received:
{"@@redux-saga/IO": true, "PUT": {"action": [Function mockConstructor], "channel": null}}
Difference:
Compared values have no visual difference.
Do you have any ideas about why it doesn't work only for actions? (I am using sagaHelper from 'redux-saga-testing' for my tests)
Thanks. printfx000.