golden_variant 0.1.2
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 #
-
Add
golden_variantto your dev dependencies. -
Create a
flutter_test_config.dartfile at the root of yourtestfolder with atestExecutablefunction:
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.