verifyAsJson static method

void verifyAsJson(
  1. dynamic encodable, {
  2. Options options = const Options(),
})

Implementation

static void verifyAsJson(
  dynamic encodable, {
  Options options = const Options(),
}) {
  try {
    // Encode the object into JSON format
    final jsonContent = ApprovalConverter.encodeReflectively(
      encodable,
      includeClassName: options.includeClassNameDuringSerialization,
    );
    final prettyJson = ApprovalConverter.convert(jsonContent);

    // Call the verify method on encoded JSON content
    verify(prettyJson, options: options);
  } catch (_) {
    rethrow;
  }
}