golden_variant 0.1.2 copy "golden_variant: ^0.1.2" to clipboard
golden_variant: ^0.1.2 copied to clipboard

A convenient golden test package that allows you to perform multi-variant test.

A convenient golden test package that allows you to perform multi-variant test.

Features #

Let's say you have golden tests and want to create golden files for different types of variants:

  • different device screen sizes;
  • dark and light themes;
  • LTR and RTL fonts;
  • with and without keyboard;
  • ...

just set variants you need and pass them to composed variant:

final variant = ValueVariantComposite([
  DeviceVariant({
    Devices.ios.iPhone13,
    Devices.ios.iPad,
  }),
  ThemeVariant({ThemeMode.light, ThemeMode.dark}),
  ShowKeyboardVariant(),
]);

then use regular testWidgets:

  testWidgets(
    'MyHomePage golden test',
    (tester) async {
      await tester.pumpWidget(
        MaterialApp(
          theme: getThemeData(variant.get<ThemeMode>()),
          home: DeviceFrameWrapper(
            device: variant.get<DeviceInfo>(),
            showVirtualKeyboard: variant.get<ShowKeyboard>().show,
            child: MyApp(),
        ...
    }
    variant: variant,
  );

Check out the example.

Getting started #

  1. Add golden_variant to your dev dependencies.

  2. Create a flutter_test_config.dart file at the root of your test folder with a testExecutable function:

Future<void> testExecutable(FutureOr<void> Function() testMain) async {
  await testMain();
}

For more information, see the official Flutter documentation.

Ideas #

If you have any ideas on how to enhance this package or have any concern, feel free to make an issue.

0
likes
150
points
41
downloads

Publisher

unverified uploader

Weekly Downloads

A convenient golden test package that allows you to perform multi-variant test.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

device_frame_plus, flutter, flutter_test, package_config

More

Packages that depend on golden_variant