widget_driver_test 1.0.4 copy "widget_driver_test: ^1.0.4" to clipboard
widget_driver_test: ^1.0.4 copied to clipboard

Contains helper classes/methods for DrivableWidgets, WidgetDrivers, helps with TestDrivers mocking

example/README.md

Testing WidgetDrivers #

void main() {
  group('MyAppDriver:', () {
    late MockLocalization mockLocalization;

    setUp(() {
      mockLocalization = MockLocalization();
    });

    testWidgets('Shows correct app title', (WidgetTester tester) async {
      when(() => mockLocalization.appTitle).thenReturn('Some app title');

      final driverTester = await tester.getDriverTester<MyAppDriver>(
          driverBuilder: (context) => MyAppDriver(context),
          parentWidgetBuilder: (driverWidget) {
            return Provider<Localization>.value(
              value: mockLocalization,
              child: driverWidget,
            );
          });

      final driver = driverTester.driver;
      expect(driver.appTitle, equals('Some app title'));
    });
  });
}

To learn more about WidgetDrivers, please read the documentation for widget_driver and check tests for example app there.

2
likes
140
points
91
downloads

Publisher

verified publisherbmwtech.dev

Weekly Downloads

Contains helper classes/methods for DrivableWidgets, WidgetDrivers, helps with TestDrivers mocking

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_test, meta, mocktail, test, widget_driver

More

Packages that depend on widget_driver_test