My goal is to determine if a component method has been invoked following a store action, but I encountered an error:
expect(jest.fn())[.not].toHaveBeenCalled()
jest.fn() value must be a mock function or spy.
Received:
function: [Function bound mockConstructor]
Here's the unit test that I have written:
describe('MyComponent.spec.js', () => {
let methods = {
setLocation: jest.fn()
// more methods...
}
it('should trigger setLocation during undo/redo actions', () => {
let wrapper = mount(MyComponent, {
store,
localVue,
methods
})
store.dispatch('doUndo')
expect(wrapper.vm.setLocation).toHaveBeenCalled()
})
})
I am uncertain whether using the actual store and a local Vue instance in this context is considered a good practice.