golden_test 2.0.1
golden_test: ^2.0.1 copied to clipboard
A utility Flutter plugin for writing golden tests that streamlines adding golden tests to your project
2.0.1 #
Fixes #
- Goldens no longer fail when the widget under test builds its own app — the screenshot was taken of
find.byType(MaterialApp), which matched both the harness's app and the one under test. The test failed withmatched too many widgetsand no golden was written, including under--update-goldens. Server-driven UI, storybook-style harnesses and nested navigators all hit this. The snapshot is now anchored to a private root widget, so it resolves to a single widget whatever the builder returns. Existing goldens are byte-identical and do not need regenerating.
2.0.0 #
Breaking changes #
- Migrated to
material_ui— Flutter 3.47 decoupled Material (and Cupertino) from the core SDK into standalonematerial_ui/cupertino_uipackages on pub.dev, deprecatingpackage:flutter/material.dart.golden_testnow importspackage:material_ui/material_ui.dartinstead, and the minimum supported Flutter version is now3.47.0(Dart SDK>=3.13.0). Projects on older Flutter versions will need to stay ongolden_test1.x. - Framework localization delegates are now built in —
GlobalMaterialLocalizations,GlobalWidgetsLocalizationsandGlobalCupertinoLocalizationsare appended automatically, sogoldenTestLocalizationsDelegatesonly needs your own app's delegates. Remove the framework ones from your config; you no longer need to import them, or to depend onflutter_localizations/cupertino_uijust for tests. This also sidesteps theambiguous_importthat otherwise occurs becauseflutter_localizationsstill exports deprecated copies of the Material and Cupertino delegates thatmaterial_ui/cupertino_uinow own. Delegates you supply are resolved before the built-in ones, so overriding still works. - Network images are stubbed by default —
goldenTestStubNetworkImagesdefaults totrue, so anyNetworkImagenow resolves to a placeholder instead of failing to load. Goldens that contain network images will change: they previously captured a blank or error state and now show the placeholder, so they need regenerating. If you already stub network images yourself, note that golden_test installs its stub before the test body: adebugNetworkImageHttpClientProviderorHttpOverridesset influtter_test_config.dartis superseded — setgoldenTestStubNetworkImages = falseto keep your own. Stubs installed insideglobalSetupor a test'ssetupstill win, since those run after, and are unaffected.
New features #
- AI agent skills — the package now ships three Agent Skills under
skills/, installable withdart run skills@ get:golden_test-setup(wiringflutter_test_config.dartto your app's themes, locales and fonts),golden_test-widget(component goldens) andgolden_test-route(screen goldens). They cover which test axes are worth their cost, deriving edge cases from branches in your own formatting code, and reading a failing golden — see README § AI Agent Skills. - Built-in network image stub — golden tests no longer time out or produce flaky output when the widget tree loads images from the network. Any
NetworkImageis resolved from a placeholder out of the box, no setup required, wherever it appears —Image.network,FadeInImage, aDecorationImagein aBoxDecoration, or a custom widget. Otherdart:ioHTTP traffic is left alone, so a repository call fired from the widget tree still behaves as it did. Opt out withgoldenTestStubNetworkImages = false, or replace the placeholder viagoldenTestNetworkImageStubPng. - Image loader hook —
goldenTestImageLoaderSetupslets any package register a per-test image-loading stub, for loaders that don't go throughNetworkImage. It's a list, so several packages can register without clobbering one another.CachedNetworkImageis supported this way by the companiongolden_test_cached_network_imagepackage, which keepscached_network_imageandflutter_cache_managerout of the dependency graph of projects that don't use them — see README § CachedNetworkImage support.
Fixes #
Device.copyWithno longer dropsname— omittingnamereset it tonull, which made the golden path fall back todefaultand caused distinct devices in onesupportedDeviceslist to share a single golden file.
1.1.1 #
Fixes #
- Bundled Roboto font — The package now ships its own Roboto font, so the device frame's status bar time renders correctly in any consuming project regardless of whether it bundles Roboto itself.
1.1.0 #
Fixes #
- Async hooks now awaited —
globalSetup,setup, andtearDowncallbacks are now properly awaited insidegoldenTest, preventing race conditions with font loading,Intl.defaultLocale, and mock wiring.
Improvements #
- Typed
tagsparameter —goldenTest'stagsparameter is nowObject?(matching Flutter's owntestWidgetssignature) instead ofdynamic, with dartdoc clarifying the accepted shapes (String,Tag,Iterable).
New features #
- Text-scale matrix —
supportedTextScalesandgoldenTestSupportedTextScalesadd text scale as a test axis. Optional [AndroidFontScale] / [IosDynamicTypeScale] enums and accessibility preset lists are available.
1.0.1 #
- Fixed README images not rendering on pub.dev by using absolute URLs.
1.0.0 #
First stable release under semantic versioning; the public API is now versioned with breaking changes reserved for major bumps.
Breaking changes #
- Golden frame — Redesigned the status bar and bottom bar UI rendered around the widget under test. All existing golden screenshots will need to be regenerated (
flutter test --update-goldens).
Improvements #
- Example app — Expanded and clearer examples demonstrating real usage patterns.
- Documentation — Reworked and expanded docs so setup and options are easier to follow.
0.1.7 #
- Added
tagsparameter to properly proxy it totestWidgets
0.1.6 #
- New Feature: Added
subdirectoryparameter togoldenTestfor organizing golden files into custom subdirectories- Allows per-test configuration of golden file organization
- Useful for managing multiple apps with different design tokens
- Supports nested subdirectories (e.g.,
'design_system/v2') - Path structure:
goldens/[subdirectory]/locale/theme/[device]/name.png
0.1.5 #
-
Refactor device configuration system to support three distinct configuration levels:
- New: Added
goldenTestDefaultDevicesfor setting global default device(s) - Improved:
goldenTestSupportedDevicesnow exclusively for multi-device testing - Changed:
supportedDevicesparameter is now nullable, enabling proper configuration hierarchy - Enhanced: Device selection logic now follows clear priority: per-test override > multi-device mode > global default
- Fixed: Golden file paths now intelligently include device names only when testing multiple devices
This change makes device configuration more intuitive and eliminates the need to pass
supportMultipleDevices: truejust to use a globally-defined single device. - New: Added
-
Improved formatting
-
Updated dependencies
-
Updated example project
-
Updated documentation
-
Drop deprecated .withOpacity
0.1.4 #
Fix directory for generating failure screenshots.
0.1.3 #
Add option to precache assets.
0.1.2 #
Add option to set difference tolerance at which tests are considered failing.
0.1.1 #
Add read.me to example project.
0.1.0 #
Initial release of goldenTest method which helps writing Golden Tests very easily by pumping Flutter Widgets.
Features:
goldenTest- utility method for generating screenshots- Supporting multiple locales.
- Supporting multiple localizations.
- Supporting light and dark mode.