Integration test default golden-file comparators changed on Android and iOS.
Summary
#
Unless a user-defined goldenFileComparator
is set, either manually in a
test, or using a flutter_test_config.dart file, Android and iOS devices
and emulators/simulators have a new default that proxies to the local host
filesystem, fixing a long-standing bug (#143299).
Background
#
The package integration_test, and its integration with
flutter_test
has historically had a bug where using matchesGoldenFile
or similar APIs
where a FileSystemException was thrown.
Some users may have worked around this issue by writing and using a custom
goldenFileComparator:
import 'package:integration_test/integration_test.dart';
import 'package:my_integration_test/custom_golden_file_comparator.dart';
void main() {
goldenFileComparator = CustomGoldenFileComparatorThatWorks();
// ...
}
Such workarounds are no longer necessary, and if type checking the default, will no longer work as before:
if (goldenFileComparator is ...) {
// The new default is a new (hidden) type that has not existed before.
}
Migration guide
#In most cases, we expect users to have to do nothing - this will be in a sense new functionality that replaced functionality that did not work and caused an unhandled exception which would fail a test.
In cases where users wrote custom test infrastructure and comparators, consider
instead removing the goldenFileComparator
overrides, and instead rely on
the (new) default which should work as expected:
import 'package:integration_test/integration_test.dart';
import 'package:my_integration_test/custom_golden_file_comparator.dart';
void main() {
goldenFileComparator = CustomGoldenFileComparatorThatWorks();
// ...
}
Fun fact: The existing code that was used for the web platform was reused.
Timeline
#
Landed in version: 3.29.0-0.0.pre
Stable release: 3.32
References
#Relevant APIs:
-
flutter_test, which talks aboutflutter_test_config.dartand its capabilities. -
goldenFileComparator, which implements comparison, and is user-configurable.
Relevant Issues:
- Issue 143299, one of many user reports about the long-standing bug.
-
Issue 160043, which explains in technical detail why
matchesGoldenFilefailed.
Relevant PRs:
Unless stated otherwise, the documentation on this site reflects Flutter 3.38.1. Page last updated on 2025-10-28. View source or report an issue.