I have the following test:
describe('Form', () => {
let store;
let wrapper;
beforeEach(() => {
store = mockStore(mockData);
wrapper = mount(
<Provider store={store}>
<Form />
</Provider>
);
});
it('handleForm calls uses validate() for validation', () => {
const instance = wrapper.instance();
const submitFormButton = wrapper.find('.submitFormButton');
submitFormButton.simulate('click');
console.log(instance); // null
});
});
Any idea of what I'm doing wrong exactly?
I know that Enzyme has this thing:
NOTE: With React 16 and above, instance() returns null for stateless functional components.
but my functional component does have a state, I'm using hooks (if that changes anything) and there should be some way to access instance.componentMethod() still, right?