Skip to content

Commit 0d02623

Browse files
stephencelismac-gallagher
authored andcommitted
Better surface diff tool configuration (pointfreeco#469)
* Update README.md * Update AssertSnapshot.swift * Update AssertSnapshot.swift
1 parent 05d5f7c commit 0d02623

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ end
195195
- **Supports any platform that supports Swift.** Write snapshot tests for iOS, Linux, macOS, and tvOS.
196196
- **SceneKit, SpriteKit, and WebKit support.** Most snapshot testing libraries don't support these view subclasses.
197197
- **`Codable` support**. Snapshot encodable data structures into their [JSON](Documentation/Available-Snapshot-Strategies.md#json) and [property list](Documentation/Available-Snapshot-Strategies.md#plist) representations.
198-
- **Custom diff tool integration**.
198+
- **Custom diff tool integration**. Configure failure messages to print diff commands for [Kaleidoscope](https://kaleidoscope.app) (or your diff tool of choice).
199+
``` swift
200+
SnapshotTesting.diffTool = "ksdiff"
201+
```
199202

200203
## Plug-ins
201204

Sources/SnapshotTesting/AssertSnapshot.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,16 @@ public func verifySnapshot<Value, Format>(
299299

300300
let diffMessage = diffTool
301301
.map { "\($0) \"\(snapshotFileUrl.path)\" \"\(failedSnapshotFileUrl.path)\"" }
302-
?? "@\(minus)\n\"\(snapshotFileUrl.path)\"\n@\(plus)\n\"\(failedSnapshotFileUrl.path)\""
302+
?? """
303+
@\(minus)
304+
"\(snapshotFileUrl.path)"
305+
@\(plus)
306+
"\(failedSnapshotFileUrl.path)"
307+
308+
To configure output for a custom diff tool, like Kaleidoscope:
309+
310+
SnapshotTesting.diffTool = "ksdiff"
311+
"""
303312
return """
304313
Snapshot does not match reference.
305314

0 commit comments

Comments
 (0)