Skip to content

Commit 3daac0c

Browse files
authored
Update readme (#152)
1 parent 17b2be4 commit 3daac0c

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,26 @@ The gallery also supports macOS. However, snapshotting does not support macOS.
3333

3434
## Local Snapshot Generation
3535

36-
The [EmergeTools snapshot testing service](https://docs.emergetools.com/docs/snapshot-testing) automatically handles hosting and diffing your snapshot tests. This Swift Package can be used for locally debugging the snapshots by generating images for each preview as part of a XCTest. You’ll need a UI test target that imports the `SnapshottingTests` and `Snapshotting` products from this package. Create a test that inherits from `PreviewTest` like this:
36+
The [EmergeTools snapshot testing service](https://docs.emergetools.com/docs/snapshot-testing) automatically handles hosting and diffing your snapshot tests. This Swift Package can be used for locally debugging the snapshots by generating images for each preview as part of a XCTest. You’ll need a unit test target that imports the `SnapshottingTests` product from this package. Create a test that inherits from `SnapshotTest` like this:
3737

3838
```swift
39-
import Snapshotting
4039
import SnapshottingTests
4140

42-
class MyPreviewTest: PreviewTest {
43-
44-
override func getApp() -> XCUIApplication {
45-
return XCUIApplication()
46-
}
41+
class DemoAppPreviewTest: SnapshotTest {
4742

43+
// Return the type names of previews like "MyApp.MyView._Previews" to selectively render only some previews
4844
override func snapshotPreviews() -> [String]? {
4945
return nil
5046
}
47+
48+
// Use this to exclude some previews from generating
49+
override func excludedSnapshotPreviews() -> [String]? {
50+
return nil
51+
}
5152
}
5253
```
5354

54-
Note that there are no test functions; they are automatically added at runtime by `PreviewTest`. You can return a list of previews from the `snapshotPreviews()` function based on what preview you are trying to locally validate. The previews will be added as attachements in Xcode’s test results. The test must be run on an iOS simulator (not device).
55+
Note that there are no test functions; they are automatically added at runtime by `SnapshotTest`. You can return a list of previews from the `snapshotPreviews()` function based on what preview you are trying to locally validate. The previews will be added as attachements in Xcode’s test results. The test must be run on an iOS simulator (not device).
5556

5657
> [!NOTE]
5758
> When you use Preivew macros (`#Preview("Display Name")`) the name of the snapshot uses the file path and the name, for example: "MyModule/MyFile.swift:Display Name"
@@ -60,22 +61,22 @@ Note that there are no test functions; they are automatically added at runtime b
6061

6162
### Accessibility Audits
6263

63-
Xcode 15 [accessibility audits](https://developer.apple.com/documentation/xctest/xcuiapplication/4191487-performaccessibilityaudit) can also be run locally on any preview. By default they will use all audit types. To customize the behavior you can override the following functions in your test:
64+
Xcode 15 [accessibility audits](https://developer.apple.com/documentation/xctest/xcuiapplication/4191487-performaccessibilityaudit) can also be run locally on any preview. They are run in a UI test (rather than unit test). To enable these tests, inherit from `AccessibilityPreviewTest`. By default they will use all audit types. To customize the behavior you can override the following functions in your test:
6465

6566
```swift
66-
override func enableAccessibilityAudit() -> Bool {
67-
true
68-
}
67+
import SnapshottingTests
68+
import Snapshotting
69+
70+
class DemoAppAccessibilityPreviewTest: AccessibilityPreviewTest {
6971

70-
@available(iOS 17.0, *)
7172
override func auditType() -> XCUIAccessibilityAuditType {
7273
return .all
7374
}
7475

75-
@available(iOS 17.0, *)
7676
override func handle(_ issue: XCUIAccessibilityAuditIssue) -> Bool {
7777
return false
7878
}
79+
}
7980
```
8081

8182
See the demo app for a full example.

0 commit comments

Comments
 (0)