| library | version
| ------------------- | -------
| enzyme | "^3.8.0"
| react | "^16.7.0
| react-dom | "^16.7.0"
| react-test-renderer | "^16.7.0"
| adapter (below) | "^1.7.1"
My project/Teste component:
I'm having trouble connecting the test with the component to the test reports, I noticed that a lot of people posted some issue about it, but checking them out and running tests like these issues did not succeed. Anyway, I have a form and I need to connect it to the redux to give sequence in the tests, but in the way that I have implemented today, the return is:
Invariant Violation: Passing redux store in props has been removed and does not do anything. To use a custom Redux store for specific components, create a custom React context with React.createContext(), and pass the context object to React-Redux's Provider and specific components like:
It looks like you're using react-redux v6, which i don't believe is ergonomically compatible with enzyme yet. Try v5.
Okay, I think we have a breakthrough, kkkk
I downgraded, but now I do not understand why my tests do not find the element to accomplish the simulate with click
I'm doing it this way:
fit('teste', () => {
store = mockStore(INITIAL_STATE);
wrapper = shallow(
<FormDocumentos
match={INITIAL_STATE.match}
values={newDocumentos}
/>,
{ context: { store } },
).dive();
wrapper.find('button').simulate('click');
console.log(store.getActions());
});
You're using shallow, and FormDocumentos renders a component that's wrapped in two HOCs - you need one .dive() per HOC, and you only have one.
This seems answered.
Most helpful comment
It looks like you're using react-redux v6, which i don't believe is ergonomically compatible with enzyme yet. Try v5.