As in the topic I would like to test react component methods that have HOC.
Usually I did it this way:
describe("component method", () => {
it("returns with null or undefined value", () => {
const wrapper = shallow(<Component />);
expect(wrapper.instance().methodName());
});
});
but right now I have component that needs store so I am trying to do it this way:
describe("component method", () => {
it("returns with null or undefined value", () => {
const wrapper = shallow(<Component store={store} />);
expect(wrapper.instance().methodName());
});
});
of course store is defined:
const mockStore = configureMockStore();
let store;
but I get error
TypeError: wrapper.instance(...).methodName is not a function
Could it be because my component is wrapped like this?
export default withSocket(Component);
If yes how can I solve it?
Aucun commentaire:
Enregistrer un commentaire