I have a test case where I'd like to count how many times an action is called. To do this, I'm using a spy:
import * as actions from "./actions"; // actions = { myAction: () => (/* etc */) }
import expect from "expect";
const spy = expect.spyOn(actions, "myAction");
doStuffDispatchingMyAction()
expect(spy.calls.length).toEqual(1); // throws!
Redux throws an error: Actions must be plain objects. Use custom middleware for async actions. Is this case related to this issue? How could I spy an action?
My guess is that you want expect.spyOn(...).andCallThrough().
Otherwise you're dispatching undefined.
Awesome thanks!
Most helpful comment
My guess is that you want
expect.spyOn(...).andCallThrough().Otherwise you're dispatching
undefined.