You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,25 +33,26 @@ The gallery also supports macOS. However, snapshotting does not support macOS.
33
33
34
34
## Local Snapshot Generation
35
35
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:
37
37
38
38
```swift
39
-
importSnapshotting
40
39
importSnapshottingTests
41
40
42
-
classMyPreviewTest: PreviewTest {
43
-
44
-
overridefuncgetApp() -> XCUIApplication {
45
-
returnXCUIApplication()
46
-
}
41
+
classDemoAppPreviewTest: SnapshotTest {
47
42
43
+
// Return the type names of previews like "MyApp.MyView._Previews" to selectively render only some previews
48
44
overridefuncsnapshotPreviews() -> [String]? {
49
45
returnnil
50
46
}
47
+
48
+
// Use this to exclude some previews from generating
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).
55
56
56
57
> [!NOTE]
57
58
> 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
60
61
61
62
### Accessibility Audits
62
63
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:
0 commit comments