I am currently trying to perform a full integration test of my redux store using enzyme.
The action "evaluateInput" triggers a Redux saga and the sage will trigger one or two actions which thenb update the state in reducers.
The store I am using for my tests is calling the saga correctly and is also working fine based on the logs that are displayed.
My testing code is the following:
store.dispatch(evaluateInput('test'));
const newState = store.getState();
const expectState = {
...initialState,
success: false,
inputs: [
'test'
]
}
expect(newState).toEqual(expectState);
What I don't understand is that the test above actually succeeds. I am dispatching an action on the store and am retrieving the state on the next row (without subscribing to the store) and it looks like the test actually waits for the saga to complete (I tried adding a 1 second delay in my saga and I could see that the tests were running one second longer but were still succeeding)
It looks like the 2nd row only gets executed once the dispatch action of the first row has finished executing, which is not how store.dispatch() is usually working.
Are the tests in jest/enzyme running only on a single thread or what could be the reason for that behaviour ?
I am actually quite happy about that, but I don't unsderstand it...
Aucun commentaire:
Enregistrer un commentaire