|
1 | 1 | # swift-snapshot-testing-plugin-heic
|
2 | 2 |
|
3 |
| -# swift-snapshot-testing-plugin-heic |
4 |
| - |
5 | 3 | This repo is an experimental use of this branch(https://github.com/pointfreeco/swift-snapshot-testing/pull/904) that contains a PluginAPI for `swift-snapshot-testing`.
|
6 | 4 |
|
7 | 5 | The goal of this is to show how easy it is to build a plugin.
|
8 | 6 |
|
9 | 7 | ## Usage
|
10 | 8 |
|
11 |
| -- Add this project to dependencies inside your `Package.swift` -> `.package(url: "https://github.com/mackoj/swift-snapshot-testing-plugin-heic.git", revision: "0.0.1"),`. |
12 |
| -- Then add this to your test target `.product(name: "HEICImageSerializer", package: "swift-snapshot-testing-plugin-heic"),`. |
13 |
| -- Then add this to the top of your test file `import HEICImageSerializer` and in the `setUp()` add this `SnapshotTesting.imageFormat = HEICImageSerializer.imageFormat`. |
| 9 | +To utilize the HEIC image serializer in your tests, follow these steps: |
| 10 | + |
| 11 | +1. **Add the Dependency**: Include this project as a dependency in your `Package.swift` file: |
| 12 | + |
| 13 | + ```swift |
| 14 | + .package(url: "https://github.com/mackoj/swift-snapshot-testing-plugin-heic.git", revision: "0.0.1"), |
| 15 | + ``` |
| 16 | + |
| 17 | +2. **Link to Your Test Target**: Add the HEICImageSerializer to your test target's dependencies: |
| 18 | + |
| 19 | + ```swift |
| 20 | + .product(name: "HEICImageSerializer", package: "swift-snapshot-testing-plugin-heic"), |
| 21 | + ``` |
| 22 | + |
| 23 | +3. **Import and Set Up**: In your test file, import the serializer and set the image format in the `setUp()` method: |
| 24 | + |
| 25 | + ```swift |
| 26 | + import HEICImageSerializer |
| 27 | + |
| 28 | + override class func setUp() { |
| 29 | + SnapshotTesting.imageFormat = HEICImageSerializer.imageFormat |
| 30 | + } |
| 31 | + ``` |
| 32 | + |
| 33 | +4. **Per Assertion**: Alternatively, specify the image format for individual assertions: |
| 34 | + |
| 35 | + ```swift |
| 36 | + assertSnapshot(of: label, as: .image(precision: 0.9, format: .heic)) |
| 37 | + ``` |
14 | 38 |
|
15 | 39 | ## TODO
|
16 | 40 |
|
|
0 commit comments