jeudi 29 octobre 2020

Test onTap behaviour

I would like to test that when I am tapping a button, the user is routed to the next page. This works in the UI. I introduced the test but I get the following error: The following TestFailure object was thrown running a test: Expected: exactly one matching node in the widget tree Actual: _WidgetTypeFinder:<zero widgets with type "MyNextView" (ignoring offstage widgets)> Which: means none were found but one was expected

What am I doing wrong?

testWidgets('Button tap routes to next page', (WidgetTester tester) async {
    final button = createButton();
    await tester.pumpWidget(button);
    
    await tester.tap(find.byWidget(button));
    expect(find.byType(MyNextView), findsOneWidget);
  });

Aucun commentaire:

Enregistrer un commentaire