Skip to main content

hydra_test 0.1.0 copy "hydra_test: ^0.1.0" to clipboard
hydra_test: ^0.1.0 copied to clipboard

Test helpers for the hydra package. Run a widget test once per breakpoint, or set the test screen to a breakpoint.

hydra_test #

Test helpers for hydra: run a widget test once per breakpoint, or set the test screen to a breakpoint.

Installation #

flutter pub add dev:hydra_test
import 'package:hydra_test/hydra_test.dart';

Every breakpoint #

HydraVariant runs a testWidgets once per breakpoint, with the test screen resized to it:

final breakpoints = HydraVariant();

testWidgets('shows the navigation for the screen', variant: breakpoints,
    (tester) async {
  await tester.pumpWidget(const MyApp());

  final wide = breakpoints.currentValue! >= Breakpoint.medium;
  expect(find.byType(NavigationRail), wide ? findsOneWidget : findsNothing);
});

The test shows up once per breakpoint, as shows the navigation for the screen (variant: mini) and so on.

Pick breakpoints and pass the behaviour your app uses:

final breakpoints = HydraVariant(
  breakpoints: {Breakpoint.mini, Breakpoint.large},
  behaviour: const HydraBehaviour.material(),
);

One breakpoint #

setBreakpoint resizes the test screen for a single test and restores it afterwards:

testWidgets('shows a bottom bar on phones', (tester) async {
  tester.setBreakpoint(Breakpoint.mini);
  await tester.pumpWidget(const MyApp());

  expect(find.byType(NavigationBar), findsOneWidget);
});

Screen sizes #

Each breakpoint gets its smallest width, so tests also check the edge of every range: small, medium and large start exactly at their breakpoint, mini is 360 px wide. The height is 800 px unless you pass another one; without orientation awareness it is raised to at least the width, as Hydra then reads the shortest side.

License #

MIT

0
likes
150
points
0
downloads

Documentation

API reference

Publisher

verified publisherkazhdan.dev

Weekly Downloads

Test helpers for the hydra package. Run a widget test once per breakpoint, or set the test screen to a breakpoint.

Homepage
Repository (GitHub)
View/report issues

Topics

#responsive #testing #breakpoint

License

MIT (license)

Dependencies

flutter, flutter_test, hydra

More

Packages that depend on hydra_test