Skip to content
pubscout

approval_tests

1.7.2, released 7 weeks ago by shodev.live

Approval tests implementation in Dart for snapshot and complex object testing.

$ flutter pub add approval_tests
Source repository

What it does

Approval tests provide an alternative to traditional assertions by taking a snapshot of test results (such as long strings, collections, or JSON objects) and comparing them against a saved approved file. If a mismatch occurs, reporters highlight the differences.

AI-written summary of version 1.7.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Testing objects with complex values, long strings, or many properties
  • Verifying complex JSON model outputs against a baseline snapshot
  • Running unit tests where exact string or text output comparison is required

Skip it when

  • Testing simple primitive equality where standard expect(actual, equals(expected)) is sufficient
  • Projects requiring heavy visual/UI golden testing specifically for Flutter widgets (use approval_tests_flutter instead)

Strengths

  • Simplifies assertions for large or complex structured outputs
  • Supports automatic file generation and CLI-based review workflows
  • Includes atomic text writing and strict mode options for CI environments

Weaknesses

  • Requires maintaining approved baseline files alongside source or test code
  • Depends on correct file naming and path resolution conventions

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
6

Add approval_tests to dev_dependencies/dependencies in pubspec.yaml and configure test files.

Approvals.verify(response, options: const Options(missingApprovedPolicy: MissingApprovedPolicy.writeReceivedAndFail));

Alternatives

Packages that do the same job and could replace approval_tests.

Works with

Packages commonly used together with approval_tests: ones it builds on, ones built on it, and its own family.