Skip to content

Testing

This guide shows simple patterns to test guards and composed pipelines.

Focus on onNavigation behavior and assert resolver interactions.

test('AuthGuard redirects when unauthenticated', () async {
final resolver = _FakeResolver();
final guard = AuthGuard(isAuthenticated: () async => false);
await guard.onNavigation(resolver, _ctx, _state);
expect(resolver.redirectedTo, '/login');
});

Wrap guards with guardAll, guardAnyOf, or guardOneOf and assert final outcome using a fake resolver.

See also: API Reference and Core Concepts.