Splash screen test fails

53 views Asked by At

I'm trying to test Splash Screen (It has the app name). but the test fails.

I tried fakeAsync But Nothing changed.

void main() {
  setUpAll(() {
    configureDependencies();
  });
  testWidgets('home page test', (tester) async {
    // Build our app and trigger a frame.
    reRegister<AppInitUseCase>(const AppInitUseCase());
    reRegister<MockMainMenuPresenter>(MockMainMenuPresenter());
    await tester.pumpWidget(MainMenuPage(presenter: getIt()));
    // fakeAsync((async) {
      expect(
        find.text(
          appLocalizations.appTitle,
        ),
        findsOneWidget,
      );
    });
  // });
}

Error: A value of type 'void Function(String, Future Function(WidgetTester), {int? retry, bool semanticsEnabled, bool? skip, dynamic tags, Timeout? timeout, TestVariant<Object?> variant})' can't be assigned to a variable of type 'FutureOr Function(String, Future Function(WidgetTester), {Duration? initialTimeout, bool semanticsEnabled, bool? skip, dynamic tags, Timeout? timeout, TestVariant<Object?> variant})'.

I tried fakeAsync But Nothing changed.

1

There are 1 answers

0
FadyFouad On

The test fails because the mainMenuPresenter is not registered. The MainMenuPage constructor expects a MainMenuPresenter to be registered in the dependency injection container, but it is not.