approval_tests_flutter 1.5.0
approval_tests_flutter: ^1.5.0 copied to clipboard
Approval Tests implementation in Dart (Flutter). Inspired by ApprovalTests.
1.5.0 #
Fixed #
- Widget-name cache writes are now atomic.
flutter testruns test files in parallel processes that share one cache file, so the previous single write was observable by another process as a truncated file — a short read drops names, which silently drops lines from a snapshot. - Widget-name discovery no longer throws
ArgumentErroron Windows.AnalysisContextCollectionrejects a path that is not absolute and normalized; theliband Dart SDK paths were built by string concatenation. - Cache freshness is validated by fingerprint instead of newest modification time. The old check missed a deleted non-newest file, a checkout with backdated timestamps, and a timestamp-preserving rename, and it treated a write racing an edit as fresh. Any cache problem is now a rescan, never an error.
- The cache is byte-stable: discovered sources and class names are sorted.
- The analysis context is disposed, so its driver no longer outlives
setUpAll. - Blocking
listSync/createSync/writeAsStringSynccalls inside the async setup path are now awaited. printExpects(widgetTypes: ...)no longer ignores its argument after the first call. A one-shot latch meant only the first set was ever registered.- The intl reverse lookup reloads when
pathToStringschanges. Its "already loaded" flag was checked but never set, so the file was re-read on every call, and a different path could never win.
Changed #
- Capture state — registered types and names, previous-capture memory, the localization lookup, and the intl string holder — moved out of library globals into an explicit session.
- Added
ApprovalWidgets.tearDownAll(), which discards that session. It is optional: omitting it reproduces the previous behaviour exactly. Add it when one test file has groups with different registrations, since aregisterTypescall otherwise stays in effect for every later group in the file and changes their snapshots. registerTypeskeeps its signature but now writes into the current session.printExpects(widgetNames: ...)adds to the session's registered names instead of replacing them, so a narrower set no longer hides names discovered bysetUpAll. This affects console output only, never an approved file.- Added
pathas a direct dependency; it was already resolved transitively.
Removed #
loadWidgetNames()and theStringApprovedExtension.endWithNewlinehelper insrc/common.dart, both unused after the discovery rewrite. Neither was exported from the package's public API.
Snapshot output is unchanged. No *.approved.txt needs re-approving.
Internal #
- Expanded deterministic coverage for widget metadata and expect generation, finder and pump policies, semantics and golden approvals, widget-name cache failures, and bounded Windows rename retries.
- Reached 100% executable line coverage (594/594 lines); all 100 test executions pass.
1.4.1 #
- Added
WidgetActionPumpPolicysotapWidget()callers can explicitly choose no pump, one pump, a fixed-duration pump, or bounded settling. - Deprecated
tapWidget(shouldPumpAndSettle: ...). Existing calls still settle by default throughout 1.x; migrate to the explicitpumpPolicyparameter. - Approval capture helpers remain caller-controlled and never pump or settle implicitly.
1.4.0 #
- Fix (behavior change):
approvalTest()now writes a full, self-contained snapshot of the widget tree on every call. Previously a second call in the same test emitted only the delta from the prior call, producing snapshots that could not be reviewed in isolation. Existing approved files that relied on the old delta output must be re-approved. - Snapshot lines are now sorted deterministically, so approvals no longer flake on widget tree-traversal order.
- Added
tester.approvalSemantics()— approval testing of the rendered accessibility (semantics) tree (labels, values, hints, tooltips, identifiers, actions); geometry is omitted so output is stable across platforms. - Added
tester.approvalGolden(finder)— golden/pixel approvals named to sit alongside the text approvals; runflutter test --update-goldensto (re)create the image. - Exported the
expectWidget/tapWidget/findByfinder helpers andregisterTypes, and exposedwidgetTypes/widgetNamesontester.printExpects(). - Removed the cold-start
flutter --versionsubprocess; the Dart SDK is now resolved fromFLUTTER_ROOT, making widget-name extraction faster and not dependent onflutterbeing onPATH. - Removed the unused
matchdependency. - Internal cleanup: replaced the
Completer/.thenwrappers withasync/await(failures now propagate instead of hanging to timeout), guarded the analyzer parse-result cast, fixed the staleApproved.initialize()setup hint, and stopped tracking the generated.approval_tests/cache.
1.3.2 #
- Raised the
analyzerconstraint to>=12.0.0 <14.0.0to resolve a version conflict withflutter_teston current Flutter/Dart SDKs, whose pinnedtest/test_apirequire analyzer 12+. - Migrated widget-name extraction to the analyzer 12 AST API (
ClassDeclaration.namePart.typeName), replacing the removednametoken getter. - Note: this drops support for analyzer 8–11 (older Flutter SDKs).
1.3.1 #
- Fixed
loadWidgetNamesto return an empty string when the widget cache file is missing, avoidingLateInitializationError. - Restored intl reverse-lookup loading by re-enabling JSON parsing in
loadEnStringReverseLookup. - Updated
WidgetMeta.hashCodeto match its equality semantics, ensuring set/map deduplication works as intended. - Added regression tests covering widget name loading, intl reverse lookup, and
WidgetMetaequality. - Declared an upper bound on the supported Dart SDK (
<4.0.0) to satisfy pub publishing requirements. - Added explicit platform support metadata (Android, iOS, Linux, macOS, Windows) so pub scoring can detect supported platforms.
- Replaced the bundled license text with the standard Apache 2.0 wording recognized by pub.dev.
- Added a minimal
example/main.dartshowcasing a widget approval test. - Updated dependency constraints (for example
approval_testsnow targets 1.3.3) to stay aligned with upstream packages. ContextLocatorreplaced byAnalysisContextCollection
1.1.6 #
- Upgraded all dependencies to actuals.
1.1.3 #
- Updated README.md file: fix links.
1.1.2 #
- Added CLI additional options:
Usage:dart run approval_tests:review [arguments]- Arguments:
--helpPrint this usage information.--listPrint a list of project .received.txt files.<index>Review an .received.txt file indexed by --list.<path/to/.received.txt>Review an .received.txt file.
- Arguments:
1.1.1 #
- Updated README.md file.
1.1.0 #
- Breaking release:
- Added new reporter:
GitReporter. It allows you to usegitto view the differences between the received and approved files. - Added support to approve files using CLI. Now you can approve files using the command line:
dart run approval_tests:review - Added support to use ApprovalTests during widget tests.
- Added header to generated files. For resolved issues you can add this to approved files:
'# This file was generated by approval_tests. Please do not edit.\n' - Some minor changes and code improvements. Thanks to Richard Coutts
- Added new reporter:
1.0.0 #
- Initial major release.
0.5.1 #
- Updated documentation.
- Updated dependencies.
- Updated
README.mdfile. - Updated
TODO.mdfile. - Rewrited comparators. Now it is only FileComparator.
- Rewrited Scrubbers: regex scrubber, date scrubber.
- Now, first run automatically create approved snapshot. You can approve another snapshot by setting
approveResulttotrueand using Diff Tool. - Completely rewritten
CommandLineReporter. There were changes with the comparison method, as well as highlighting by color the places where there are differences. Green - approved. White text on red background - Differences in received file. - Internal updates such as:
- Adding android studio installation via github actions to test Diff Reporter on different devices.
- Full code test coverage after significant changes.
- Changes to getting file name and path depending on platform.
0.4.6 #
- Updated dependencies. Removed
dclipackage. - Issue https://github.com/approvals/ApprovalTests.Dart/issues/3 was fixed.
- Minor changes:
IDEComparatornow gets the currentStackTraceif an error occurs.
0.4.5 #
- Updated dependencies and actions versions.
- Updated Logger's output: now it is more informative.
- Updated
CONTRIBUTING.mdfile: added Arlo's Commit Notation.
0.4.4 #
- Added setup visual studio code action to the
build_and_testworkflow for testIDEComparator.
0.4.3 #
- Completed coverage of the project with tests. Now the project has 100% coverage.
0.4.2 #
- Autopublish to
pub.devif the version inpubspec.yamlhas been changed by auto adding a new tag to the repositories. - Codecov added to
githubactions. Codecov badge, graph was added toREADME.md. - Added
mdsnippetstogithubactions. And example snippets added toREADME.md. - Added
ApprovalTests.Dart.StarterProject. You can find it in theREADME.mdfile.
0.3.9 #
- Fix with default file path if package from
pub.dev. - Gilded rose moved to starter project.
- Code formatted.
0.3.8 #
- Test publish action with new version:
v0.3.8.
0.3.6-dev #
- Updated
pubspec.yamlfile: changed homepage.
0.3.5-dev #
- The repository has been moved to Approvals.
- Fixed bug with checking of strings received from
txtfile. - Added
GithubActions. - Added
dependabot. - Updated
README.mdfile. - Updated
TODO.mdfile.
0.3.3-dev #
- Updated
README.mdfile.
0.3.2-dev #
- Default
lintsreplaced bysizzle_lints. - Updated
analysis_optionsfile. - Updated
README.mdfile.
0.3.1-dev #
- Updated
README.mdfile.
0.3.0-dev #
- Approval was refactored.
- Added tests.
- Code formatted.
deleteReceivedFilefield was added to theApprovalTestsclass. If it is set totrue, the received file will be deleted after test. By default, it is set tofalse.logErrorsfield was added to theApprovalTestsclass. If it is set totrue, the errors will be logged. By default, it is set totrue.logResultsfield was added to theApprovalTestsclass. If it is set totrue, the success results will be logged. By default, it is set totrue.
0.2.1-dev #
- Fix:
approval_dartchanged toapproval_tests. - Code formatted.
0.2.0-dev #
- I rewrote the main functions of the class. Now you can use several comparison options.
- Added methods for comparing
JSONstrings. - Added methods for array comparison.
- Improved documentation.
- Added more examples: each method has its own small example.
0.1.0-dev #
- Added
verifyAllmethod to verify array of items (or use array as inputs). - Added
verifyAllCombinationsAsJsonmethod to verify all combinations of items asJSON. - Updated
README.mdfile.
0.0.9-dev #
- Updated
README.mdfile.
0.0.8-dev #
- Updated
README.mdfile: added examples, more info.
0.0.7-dev #
- Comparator completed, some refactoring. Updated
README.mdfile.
0.0.6-dev #
- Some updates with
README.mdfile.
0.0.5-dev #
- First working version, need to expand functionality and add more flexibilty. Also need to add more tests.
0.0.1-dev #
- Initial version.