Implementation
Future<void> toMatchImageSnapshot(String id,
{List<RegExp>? removeExps}) async {
final currentSnapshot =
await Snapshot.getSnapshotFromFile(id, SnapshotType.image, options);
final newSnapshot = await Snapshot.getSnapshotFromDriver(
id, SnapshotType.image, driver, removeExps);
if (newSnapshot == null) {
throw Exception(
'SnapshotTest: (toMatchRenderTreeSnapshot) New Snapshot is null');
}
if (currentSnapshot == null || options.forceCaptureMode) {
await newSnapshot.save(options);
return;
}
try {
currentSnapshot.matchesSnapshot(newSnapshot);
return;
} on TestFailure catch (_) {
await saveFailure(currentSnapshot, newSnapshot);
rethrow;
} catch (_) {
rethrow;
}
}