Skip to content

Commit 6bd40ad

Browse files
authored
Merge pull request #28 from NickEntin/entin/switch-default-snapshot-engine
Switch default subspec to SnapshotTesting
2 parents 1b6ed10 + 63aa792 commit 6bd40ad

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed

AccessibilitySnapshot.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
1212

1313
s.ios.deployment_target = '12.0'
1414

15-
s.default_subspecs = 'Core', 'iOSSnapshotTestCase'
15+
s.default_subspecs = 'Core', 'SnapshotTesting'
1616

1717
s.subspec 'Core' do |ss|
1818
ss.source_files = 'AccessibilitySnapshot/Core/Classes/**/*.{swift,h,m}'

Example/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ target 'AccessibilitySnapshotDemo' do
1010
target 'SnapshotTests' do
1111
inherit! :search_paths
1212

13-
pod 'AccessibilitySnapshot', :path => '../AccessibilitySnapshot.podspec'
13+
pod 'AccessibilitySnapshot/iOSSnapshotTestCase', :path => '../AccessibilitySnapshot.podspec'
1414
pod 'AccessibilitySnapshot/SnapshotTesting', :path => '../AccessibilitySnapshot.podspec'
1515
end
1616

Example/Podfile.lock

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
PODS:
2-
- AccessibilitySnapshot (0.3.3):
3-
- AccessibilitySnapshot/Core (= 0.3.3)
4-
- AccessibilitySnapshot/iOSSnapshotTestCase (= 0.3.3)
52
- AccessibilitySnapshot/Core (0.3.3):
63
- fishhook (~> 0.2)
74
- AccessibilitySnapshot/iOSSnapshotTestCase (0.3.3):
@@ -17,11 +14,11 @@ PODS:
1714
- iOSSnapshotTestCase/SwiftSupport (6.2.0):
1815
- iOSSnapshotTestCase/Core
1916
- Paralayout (0.9.1)
20-
- SnapshotTesting (1.7.2)
17+
- SnapshotTesting (1.8.2)
2118

2219
DEPENDENCIES:
23-
- AccessibilitySnapshot (from `../AccessibilitySnapshot.podspec`)
2420
- AccessibilitySnapshot/Core (from `../AccessibilitySnapshot.podspec`)
21+
- AccessibilitySnapshot/iOSSnapshotTestCase (from `../AccessibilitySnapshot.podspec`)
2522
- AccessibilitySnapshot/SnapshotTesting (from `../AccessibilitySnapshot.podspec`)
2623
- Paralayout (from `https://github.com/square/Paralayout`)
2724

@@ -43,12 +40,12 @@ CHECKOUT OPTIONS:
4340
:git: https://github.com/square/Paralayout
4441

4542
SPEC CHECKSUMS:
46-
AccessibilitySnapshot: 9f5bb086d87f4d797f4e047c46dcb06b0c7878f8
43+
AccessibilitySnapshot: 16a6591e103a619a370283d735bc7b89b07811b9
4744
fishhook: ea19933abfe8f2f52c55fd8b6e2718467d3ebc89
4845
iOSSnapshotTestCase: 9ab44cb5aa62b84d31847f40680112e15ec579a6
4946
Paralayout: f4d6727fca5b592eb93a7cc408e45404599a4b0a
50-
SnapshotTesting: 8caa6661fea7c8019d5b46de77c16bab99c36c5c
47+
SnapshotTesting: 38947050d13960d57a4a9c166fcf51bca7d56970
5148

52-
PODFILE CHECKSUM: 909a664616eb8ce5c087424039327435f7f366b7
49+
PODFILE CHECKSUM: 732bb9b88eb5ba688736aeb334770899a1d472c2
5350

5451
COCOAPODS: 1.9.1

README.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ AccessibilitySnapshots makes it simple to add regression tests for accessibility
99

1010
## Getting Started
1111

12-
By default, AccessibilitySnapshot uses [iOSSnapshotTestCase](https://github.com/uber/ios-snapshot-test-case) to record snapshots and perform comparisons. Before setting up accessibility snapshot tests, make sure your project is set up for standard snapshot testing. Accessibility snapshot tests require that the test target has a host application. See the [Extensions](#extensions) section below for a list of other available snapshotting options.
12+
By default, AccessibilitySnapshot uses [SnapshotTesting](https://github.com/pointfreeco/swift-snapshot-testing) to record snapshots and perform comparisons. The framework also includes support for using [iOSSnapshotTestCase](https://github.com/uber/ios-snapshot-test-case) as the snapshotting engine instead. Before setting up accessibility snapshot tests, make sure your project is set up for standard snapshot testing. Accessibility snapshot tests require that the test target has a host application. See the [Extensions](#extensions) section below for a list of other available snapshotting options.
1313

1414
### CocoaPods
1515

@@ -19,20 +19,52 @@ Install with [CocoaPods](https://cocoapods.org) by adding the following to your
1919
pod 'AccessibilitySnapshot'
2020
```
2121

22-
To use only the core accessibility parser, add a dependency on the Core subspec alone.
22+
To use only the core accessibility parser, add a dependency on the Core subspec alone:
2323

2424
```ruby
2525
pod 'AccessibilitySnapshot/Core'
2626
```
2727

28-
Alternatively, if you wish to use Pointfree's SnapshotTesting library to perform image comparisons, then you should use the following subspec instead.
28+
Alternatively, if you wish to use [iOSSnapshotTestCase](https://github.com/uber/ios-snapshot-test-case) to perform image comparisons, you can add a dependency on the `iOSSnapshotTestCase` subspec instead (or in addition - you can use both in the same project):
2929

3030
```ruby
31-
pod 'AccessibilitySnapshot/SnapshotTesting'
31+
pod 'AccessibilitySnapshot/iOSSnapshotTestCase'
3232
```
3333

3434
## Usage
3535

36+
AccessibilitySnapshot builds on top of existing snapshot frameworks to add support for snapshotting your app's accessibility. By default it uses the [SnapshotTesting](https://github.com/pointfreeco/swift-snapshot-testing) framework for snapshotting, but can be switched over to [iOSSnapshotTestCase](https://github.com/uber/ios-snapshot-test-case) as well.
37+
38+
### Getting Started with SnapshotTesting
39+
40+
AccessibilitySnapshot provides an `.accessibilityImage` snapshotting strategy that can be used with SnapshotTesting's snapshot assertions.
41+
42+
```swift
43+
func testAccessibility() {
44+
let view = MyView()
45+
// Configure the view...
46+
47+
assertSnapshot(matching: view, as: .accessibilityImage)
48+
}
49+
```
50+
51+
Snapshots can also be customized in a few ways, for example controlling when to include indicators for the accessibility activation point of each element. By default, these indicators are shown when the activation point is different than the default activation point for that view. You can override this behavior for each snapshot:
52+
53+
```swift
54+
func testAccessibility() {
55+
let view = MyView()
56+
// Configure the view...
57+
58+
// Show indicators for every element.
59+
assertSnapshot(matching: view, as: .accessibilityImage(showActivationPoints: .always))
60+
61+
// Don't show any indicators.
62+
assertSnapshot(matching: view, as: .accessibilityImage(showActivationPoints: .never))
63+
}
64+
```
65+
66+
### Getting Started with iOSSnapshotTestCase
67+
3668
To run a snapshot test, simply call the `SnapshotVerifyAccessibility` method:
3769

3870
```swift

0 commit comments

Comments
 (0)