Description
How do people approach writing widget tests when using flutter_built_redux?
One approach is to put the StoreConnection
in its own widget at the top of the tree that then instantiates a child widget (that we want to test), passing the action object and any other bits of state. We can then test the child widget directly, passing whatever state we want, and doing expectDispatched on the actions object. Other approaches include passing callbacks rather than the action object for complete separation of concerns.
The problem with this is that we're then not testing the StoreConnection
and its associated connect
function, which is a place where you can get a mismatch between whats in your state and whats in your widget. Instead, I could use a ReduxProvider
as a parent, passing in a store with the right state, but then I'm looking for state changes, and it's more like an end-to-end test. Is there a worthwhile middle ground that lets me test the connection point without testing the whole thing?