Closed dluksza closed 4 years ago
Problem is, routeName
was good for that simple case, but each Navigation method gets different parameters. Some of them had routes which I improperly called routeName
.
This is better:
1) I added a NavigateAction.type
which you can use if you just want to check the type of the navigation (NavigateType.pop
, NavigateType.push
etc).
2) As for the other action details, check the NavigateAction.details
:
expect(navigateAction.details as NavigatorDetails_PushNamed).routeName, "myRoute");
This gives you more than just the routeName
, depending on the NavigatorDetails
exact class. For example:
expect((navigateAction.details as NavigatorDetails_Replace).newRoute, "someRoute");
expect((navigateAction.details as NavigatorDetails_Replace).newRoute, "otherRoute");
Please see version [6.0.1], and tell me if it solves the problem.
Thanks, this worked!
btw. NavigatorDetails_Replace
or NavigatorDetails_PushNamedAndRemoveUntil
is descriptive, but also a bit of a mouthful, would it be possible to have something shorter?
I can't really, since I am just copying the Navigator method names: https://api.flutter.dev/flutter/widgets/Navigator/pushNamedAndRemoveUntil.html
Before 6.0 release it was possible to assert route names used in navigation actions. This gave a possibility to test screen redirects from actions.
Code like this would compile and test that action was emitted and verify the
routeName
Now in 6.0 this is not possible, because
routeName
was removed fromNavigateAction
.Is there a new way to verify dispatched action?
I've found previous implementation really useful, especially verifying app flow in unit test instead of widget or driver tests. Would be great to get this possibility back.