I am testing a middleware that throws an async action (a thunk) derivedAction
when intercepting another action originalAction
.
let nextMock: jest.Mock;
let dispatchMock: jest.Mock;
nextMock = jest.fn();
dispatchMock = jest.fn();
mockedState = {};
storeMock = {
dispatch: dispatchMock,
getState: () => mockedState,
};
myMiddleware(storeMock)(nextMock)(originalAction);
expect(dispatchMock).toHaveBeenNthCalledWith(
1,
derivedAction(derivedActionPayload)
);
The code worked under React 17, but when I switch to React 18, I receive
n: 1
Expected: [Function anonymous]
Received: [Function anonymous]
Any ideas/suggestions?