flutty_test library

Testing utilities for Flutty packages.

Classes

Device
This Device is a configuration for golden test. Can be provided for multiScreenGolden
GoldenBuilder
GoldenBuilder builds column/grid layout for it's children
GoldenToolkit
Manages global state & behavior for the Golden Toolkit This is a singleton so that it can be easily configured in one place and shared across tests
GoldenToolkitConfiguration
Represents configuration options for the GoldenToolkit. These are akin to environmental flags.

Extensions

TestingToolsExtension on WidgetTester
Extensions for a WidgetTester
WidgetFlutterBindingExtensions on TestWidgetsFlutterBinding
Convenience extensions for more easily configuring WidgetTester for pre-set configurations
WidgetTesterImageLoadingExtensions on WidgetTester
Convenience extensions on WidgetTester

Constants

smallPhone → const Device
Small phone Device (375x667) with iPhone-style safe area insets.
smallPhoneWithZoom2 → const Device
Same Device as smallPhone but with text scaled by 2.
textScaleFactorMaxSupported → const double
as of iOS 13.2.3 the max textScaleFactor a user can set is ~3.1176

Functions

defaultDeviceFileNameFactory(String name, Device device) → String
This is the default file name factory which is used by multiScreenGolden to determine the actual file name for a golden test. The given name is the name passed into multiScreenGolden.
defaultFileNameFactory(String name) → String
This is the default file name factory which is used by screenMatchesGolden to determine the actual file name for a golden test. The given name is the name passed into screenMatchesGolden.
defaultPrimeAssets(WidgetTester tester) → Future<void>
A function that waits for all Image widgets found in the widget tree to finish decoding.
legacyPrimeAssets(WidgetTester tester) → Future<void>
A function that primes all assets by just wasting time and hoping that it is enough for all assets to finish loading. Doing so is not recommended and very flaky. Consider switching to defaultPrimeAssets or a custom implementation.
loadAppFonts() → Future<void>
By default, flutter test only uses a single "test" font called Ahem.
materialAppWrapper({TargetPlatform platform = TargetPlatform.android, Iterable<LocalizationsDelegate>? localizations, NavigatorObserver? navigatorObserver, Iterable<Locale>? localeOverrides, ThemeData? theme}) → WidgetWrapper
This materialAppWrapper is a convenience function to wrap your widget in MaterialApp Wraps your widget in MaterialApp, inject custom theme, localizations, override surfaceSize and platform
multiScreenGolden(WidgetTester tester, String name, {Finder? finder, bool? autoHeight, double? overrideGoldenHeight, CustomPump? customPump, DeviceSetup? deviceSetup, List<Device>? devices, bool? skip}) → Future<void>
This multiScreenGolden will run scenarios for given devices list
noWrap() → WidgetWrapper
This noWrap is a convenience function if you don't want to wrap widgets in default materialAppWrapper
screenMatchesGolden(WidgetTester tester, String name, {bool? autoHeight, Finder? finder, CustomPump? customPump, bool? skip}) → Future<void>
A function that wraps matchesGoldenFile with some extra functionality. The function finds the first widget in the tree if finder is not specified. Furthermore a fileNameFactory can be used in combination with a name to specify a custom path and name for the golden file. In addition to that the function makes sure all images are available before
screenTestGoldens(String title, {required Widget widget, Future<void> initScreen(WidgetTester)?, Future<void> afterPumpAction(WidgetTester)?, int? waitDurationForAnimationInMs, bool onlyDark = false, bool onlyLight = false, List<Device> additionalDevices = const [], List<Device>? overrideDevices, Iterable<LocalizationsDelegate>? localizations}) → void
Full-screen golden test of a widget on multiple Devices.
simpleTestGoldens(String title, {required Widget widget, required double height, ThemeData? lightTheme, ThemeData? darkTheme, double? width, Iterable<LocalizationsDelegate>? localizations}) → void
Golden test of a single widget on a fixed surface (width x height).
testGoldens(String description, Future<void> test(WidgetTester tester), {bool? skip, Object? tags = _defaultTagObject}) → void
This testGoldens method exists as a way to enforce the proper naming of tests that contain golden diffs so that we can reliably run all goldens
testGoldensWithTextScale(String title, {required Widget widget, required double height, ThemeData? lightTheme, ThemeData? darkTheme, double? width, Iterable<LocalizationsDelegate>? localizations}) → void
Golden test of a single widget rendered at several text scale factors.

Typedefs

CustomPump = Future<void> Function(WidgetTester tester)
CustomPump is a function that lets you do custom pumping before golden evaluation. Sometimes, you want to do a golden test for different stages of animations, so its crucial to have a precise control over pumps and durations
DeviceFileNameFactory = String Function(String name, Device device)
A factory to determine a file name/path from a name and a device.
DeviceSetup = Future<void> Function(Device device, WidgetTester tester)
Function definition for allowing for device or test setup to occur for each device configuration under test
FileNameFactory = String Function(String name)
A factory to determine an actual file name/path from a given name.
PrimeAssets = Future<void> Function(WidgetTester tester)
A function that primes all needed assets for the given tester.
SkipGoldenAssertion = bool Function()
A func that will be evaluated at runtime to determine if the golden assertion should be skipped
WidgetWrapper = Widget Function(Widget)
Typedef for wrapping a widget with one or more other widgets