matchesTextGolden function

Matcher matchesTextGolden(
  1. String path, {
  2. bool update = false,
})

Matches a String against the contents of a text golden file.

If the file is missing, or update is true, the matcher writes the candidate to disk and succeeds. Otherwise it compares the candidate to the on-disk contents byte-for-byte.

The update flag is left to the caller — ux has no opinion on how regeneration is triggered. For flutter_test users, pass autoUpdateGoldenFiles so flutter test --update-goldens also updates text goldens:

import 'package:flutter_test/flutter_test.dart';
import 'package:ux/testing.dart';

expect(snapshot, matchesTextGolden(path, update: autoUpdateGoldenFiles));

Use for RPC responses, log output, formatted data — anywhere a PNG comparison doesn't fit.

Implementation

Matcher matchesTextGolden(String path, {bool update = false}) =>
    _TextGoldenMatcher(path, update: update);