Skip to content

Commit 7e472fa

Browse files
Merge branch 'main' into orm
# Conflicts: # Sources/SnapshotTesting/AssertSnapshot.swift
2 parents 022ba98 + 2d0d95e commit 7e472fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1848
-433
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 2
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let package = Package(
2121
),
2222
],
2323
dependencies: [
24-
.package(url: "https://github.com/apple/swift-syntax", "508.0.1"..<"601.0.0")
24+
.package(url: "https://github.com/swiftlang/swift-syntax", "509.0.0"..<"601.0.0-prerelease")
2525
],
2626
targets: [
2727
.target(

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,28 @@ Repeat test runs will load this reference and compare it with the runtime value.
4646
match, the test will fail and describe the difference. Failures can be inspected from Xcode's Report
4747
Navigator or by inspecting the file URLs of the failure.
4848

49-
You can record a new reference by setting the `record` parameter to `true` on the assertion or
50-
setting `isRecording` globally.
49+
You can record a new reference by customizing snapshots inline with the assertion, or using the
50+
`withSnapshotTesting` tool:
5151

52-
``` swift
53-
assertSnapshot(of: vc, as: .image, record: true)
54-
55-
// or globally
52+
```swift
53+
// Record just this one snapshot
54+
assertSnapshot(of: vc, as: .image, record: .all)
55+
56+
// Record all snapshots in a scope:
57+
withSnapshotTesting(record: .all) {
58+
assertSnapshot(of: vc1, as: .image)
59+
assertSnapshot(of: vc2, as: .image)
60+
assertSnapshot(of: vc3, as: .image)
61+
}
5662

57-
isRecording = true
58-
assertSnapshot(of: vc, as: .image)
63+
// Record all snapshots in an XCTestCase subclass:
64+
class FeatureTests: XCTestCase {
65+
override func invokeTest() {
66+
withSnapshotTesting(record: .all) {
67+
super.invokeTest()
68+
}
69+
}
70+
}
5971
```
6072

6173
## Snapshot Anything
@@ -218,9 +230,9 @@ targets: [
218230
- **`Codable` support**. Snapshot encodable data structures into their JSON and property list
219231
representations.
220232
- **Custom diff tool integration**. Configure failure messages to print diff commands for
221-
[Kaleidoscope](https://kaleidoscope.app) (or your diff tool of choice).
233+
[Kaleidoscope](https://kaleidoscope.app) or your diff tool of choice.
222234
``` swift
223-
SnapshotTesting.diffTool = "ksdiff"
235+
SnapshotTesting.diffToolCommand = { "ksdiff \($0) \($1)" }
224236
```
225237

226238
[available-strategies]: https://swiftpackageindex.com/pointfreeco/swift-snapshot-testing/main/documentation/snapshottesting/snapshotting

0 commit comments

Comments
 (0)