testing library
Testing helpers for apps that use go_router.
- MockGoRouter records navigation calls for fast widget tests.
- isAt, expectRoute and expectRedirect check where a router is.
- openDeepLink and expectDeepLink deliver links the way the operating system does.
Classes
- MockGoRouter
-
A stand-in
GoRouterfor widget tests that records every navigation call instead of building pages. - MockGoRouterProvider
-
Makes a MockGoRouter (or any
GoRouter) available to child, soGoRouter.of(context)and thecontext.gostyle helpers find it. - One navigation call recorded by a MockGoRouter.
Enums
- The kind of a NavigationCall.
Functions
-
currentLocation(
GoRouter router) → Uri -
The current location of
router, for a realGoRouteror a MockGoRouter. -
expectDeepLink(
WidgetTester tester, GoRouter router, String link, {required String opens}) → Future< void> -
Opens
linkwith openDeepLink and checks thatrouterends up atopens. -
expectRedirect(
WidgetTester tester, GoRouter router, {required String from, required String to}) → Future< void> -
Opens
fromand checks that the router ends up atto. -
expectRoute(
GoRouter router, String location, {String? reason}) → void -
Checks that
routeris showinglocation. Same asexpect(router, isAt(location)). -
isAt(
String location) → Matcher -
Matches a
GoRouterthat is showinglocation. -
openDeepLink(
WidgetTester tester, String link) → Future< void> -
Delivers
linkto the app the way the operating system does when the user taps a deep link, then waits for navigation to settle. -
pumpRouter(
WidgetTester tester, GoRouter router) → Future< void> -
Pumps a
MaterialApp.routerdriven byrouterand waits for the first page to settle.