1
resposta

pumpAndSettle timed out

Estou com versão 2.2.3 / Dart 2.13.4

import 'package:bytebank/screen/byteBankApp.dart'; import 'package:bytebank/screen/contact/formulario.dart'; import 'package:bytebank/screen/contact/lista.dart'; import 'package:bytebank/screen/dashboard.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart';

import 'matchers.dart'; import 'mocks.dart';

void main() { testWidgets('Should save a contact', (tester) async { final mockContactDao = MockContactDao();

  await tester.pumpWidget(ByteBankApp(contactDao: mockContactDao,));

  final dashBoard = find.byType(Dashboard);
  expect(dashBoard, findsOneWidget);

  final transferFeatureItem = find.byWidgetPredicate((widget) =>
     featureItemMatcher(widget, 'Transfer', Icons.monetization_on));
  expect(transferFeatureItem, findsOneWidget);

  await tester.tap(transferFeatureItem);
  await tester.pumpAndSettle();

  final contactList = find.byType(ContactList);
  expect(contactList, findsOneWidget);

  final fabNewContact = find.widgetWithIcon(FloatingActionButton, Icons.add);
  expect(fabNewContact, findsOneWidget);

  await tester.tap(fabNewContact);
  await tester.pumpAndSettle();

  final contactForm = find.byType(ContactForm);
  expect(contactForm, findsOneWidget);

}); }

Erro gerado:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following assertion was thrown running a test: pumpAndSettle timed out

When the exception was thrown, this was the stack:

#0 WidgetTester.pumpAndSettle. (package:flutter_test/src/widget_tester.dart:651:11) (elided one frame from package:stack_trace) ...

The test description was: Should save a contact ════════════════════════════════════════════════════════════════════════════════════════════════════

Test failed. See exception logs above.

1 resposta

//Tem um Bug e para passar o teste nas versões atuais usei este codigo: removi o tester.pumpAndSettle()

for (int i = 0; i < 5; i++) {
       await tester.pump(Duration(seconds: 1));
  }