pumpBloomApp method

Future<BloomTestScope> pumpBloomApp({
  1. String initialLocation = '/',
  2. List<RouteBase>? routes,
  3. List<BloomTestOverride>? overrides,
  4. Widget? home,
  5. BloomTheme? theme,
  6. Duration settleTimeout = const Duration(seconds: 5),
})

Pumps a fully configured BloomApp within an isolated test scope.

Resets global Bloom state and attaches provided overrides to the DI container. Automatically registers a tear-down handler to dispose the test scope when the test finishes.

Parameters:

  • initialLocation: The initial route path (defaults to '/').
  • routes: Custom route configurations for the test.
  • overrides: DI service overrides for mocking dependencies.
  • home: A direct root widget to render at initialLocation.
  • theme: Custom ui.BloomTheme for testing UI themes.
  • settleTimeout: Maximum duration to wait when settling animations.

Implementation

Future<BloomTestScope> pumpBloomApp({
  String initialLocation = '/',
  List<RouteBase>? routes,
  List<BloomTestOverride<dynamic>>? overrides,
  Widget? home,
  ui.BloomTheme? theme,
  Duration settleTimeout = const Duration(seconds: 5),
}) async {
  Bloom.reset();

  // Create test scope with supplied overrides
  final scope = Bloom.createTestScope(overrides: overrides);
  addTearDown(() => scope.dispose());

  final appRoutes = routes ??
      [
        if (home != null)
          BloomRouter.route(
            path: initialLocation,
            builder: (context, match) => home,
          ),
      ];

  await pumpWidget(
    BloomApp(
      title: 'Bloom Test App',
      initialLocation: initialLocation,
      routes: appRoutes,
      theme: theme,
    ),
  );

  await pumpAndSettle(const Duration(milliseconds: 100));
  return scope;
}