expectRoute function

void expectRoute(
  1. String route
)

Test helper utilities for Nylo testing.

Provides assertion methods for common testing scenarios:

  • Route assertions
  • Backpack state assertions
  • Environment variable assertions
  • Authentication assertions
  • API call assertions
  • Locale assertions

Example:

expectRoute('/home');
expectBackpackContains('user');
expectAuthenticated<User>();
expectApiCalled<UserApiService>(endpoint: '/users', times: 1);

Assert that the current route matches the expected route.

Implementation

/// Assert that the current route matches the expected route.
void expectRoute(String route) {
  final currentRoute = Nylo.getCurrentRouteName();
  expect(
    currentRoute,
    route,
    reason: 'Expected route "$route" but was "$currentRoute"',
  );
}