@@ -70,16 +70,21 @@ open class SnapshotTestCase: XCTestCase {
7070 self . wait ( for: [ tookSnapshot] , timeout: timeout)
7171 #endif
7272
73- guard let diffing = optionalDiffable else {
73+ guard let diffable = optionalDiffable else {
7474 XCTFail ( " Couldn't snapshot value " , file: file, line: line)
7575 return
7676 }
7777
7878 guard !recording, fileManager. fileExists ( atPath: snapshotFileUrl. path) else {
79- try snapshotting. diffing. toData ( diffing) . write ( to: snapshotFileUrl)
79+ let diffMessage = ( try ? Data ( contentsOf: snapshotFileUrl) )
80+ . flatMap { data in snapshotting. diffing. diff ( snapshotting. diffing. fromData ( data) , diffable) }
81+ . map { diff, _ in diff. trimmingCharacters ( in: . whitespacesAndNewlines) }
82+ ?? " Recorded snapshot: … "
83+
84+ try snapshotting. diffing. toData ( diffable) . write ( to: snapshotFileUrl)
8085 let message = recording
8186 ? """
82- Record mode is on. Recorded snapshot: …
87+ Record mode is on. \( diffMessage )
8388
8489 open " \( snapshotFileUrl. path) "
8590
@@ -100,7 +105,7 @@ open class SnapshotTestCase: XCTestCase {
100105 let data = try Data ( contentsOf: snapshotFileUrl)
101106 let reference = snapshotting. diffing. fromData ( data)
102107
103- guard let ( failure, attachments) = snapshotting. diffing. diff ( reference, diffing ) else {
108+ guard let ( failure, attachments) = snapshotting. diffing. diff ( reference, diffable ) else {
104109 return
105110 }
106111
@@ -110,7 +115,7 @@ open class SnapshotTestCase: XCTestCase {
110115 let artifactsSubUrl = artifactsUrl. appendingPathComponent ( fileName)
111116 try fileManager. createDirectory ( at: artifactsSubUrl, withIntermediateDirectories: true )
112117 let failedSnapshotFileUrl = artifactsSubUrl. appendingPathComponent ( snapshotFileUrl. lastPathComponent)
113- try snapshotting. diffing. toData ( diffing ) . write ( to: failedSnapshotFileUrl)
118+ try snapshotting. diffing. toData ( diffable ) . write ( to: failedSnapshotFileUrl)
114119
115120 if !attachments. isEmpty {
116121 #if !os(Linux)
0 commit comments