verify static method
Verifies the output against the approved file.
Implementation
static void verify(String output, {String? filePath}) {
File file = File(filePath ?? approvedPath());
if (!file.existsSync()) {
file.writeAsStringSync(output);
print("Error: Approved file does not exist.");
} else {
String approvedOutput = file.readAsStringSync();
bool isApproved = output == approvedOutput;
print("Output: '$output'\n\nApproved: '$approvedOutput'");
if (!isApproved) {
throw Exception("Output does not match the approved file.");
}
print("Output matches the approved file.");
expect(output, equals(approvedOutput));
}
}