Skip to content

Commit 7401813

Browse files
authored
Let test fail based on diff again
1 parent e630145 commit 7401813

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Sources/SnapshotTesting/AssertSnapshot.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public func verifySnapshot<Value, Format>(
267267
}
268268
#endif
269269

270-
guard let (_, attachments) = snapshotting.diffing.diff(reference, diffable) else {
270+
guard let (failure, attachments) = snapshotting.diffing.diff(reference, diffable) else {
271271
return nil
272272
}
273273

@@ -291,7 +291,18 @@ public func verifySnapshot<Value, Format>(
291291
#endif
292292
}
293293

294-
return nil
294+
let failureMessage: String
295+
if let name = name {
296+
failureMessage = "Snapshot \"\(name)\" does not match reference."
297+
} else {
298+
failureMessage = "Snapshot does not match reference."
299+
}
300+
301+
return """
302+
\(failureMessage)
303+
304+
\(failure.trimmingCharacters(in: .whitespacesAndNewlines))
305+
"""
295306
} catch {
296307
return error.localizedDescription
297308
}

0 commit comments

Comments
 (0)