The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
## What's Changed
* Added: _Inline_ Snapshot Testing (https://github.com/pointfreeco/swift-snapshot-testing/pull/764). This allows your text-based snapshots to live right in the test source code, rather than in an external file:

While the library has had experimental support for this feature since [1.5.0](https://github.com/pointfreeco/swift-snapshot-testing/releases/1.5.0) thanks to @rjchatfield (https://github.com/pointfreeco/swift-snapshot-testing/pull/199), we've finally put the finishing touches to it:
- Inline snapshot testing is available in a separate `InlineSnapshotTesting` module. To use inline snapshot testing, add a dependency on this module and update your existing imports:
```diff
-import SnapshotTesting
+import InlineSnapshotTesting
```
The feature has been rewritten to use [SwiftSyntax](https://github.com/apple/swift-syntax). While a heavyweight dependency, it is a more reasonable tool for generating Swift code than string substitution, and will be an increasingly common dependency as the de facto tool for writing Swift macros.
The main `SnapshotTesting` module does not depend on SwiftSyntax, so existing snapshot tests will not incur cost of compiling SwiftSyntax.
- The API now follows the same structure as `assertSnapshot`, except it uses a trailing closure to capture the inline snapshot. This makes it easy to update an existing snapshot test to use inline snapshots:
```diff
-assertSnapshot(of: user, as: .json)
+assertInlineSnapshot(of: user, as .json)
```
After this assertion runs, the test source code is updated in place:
```swift
assertInlineSnapshot(of: user, as: .json) {
"""
{
"id" : 42,
"isAdmin" : true,
"name" : "Blob"
}
"""
}
```
These trailing closures are easy to select in Xcode in order to delete and re-record a snapshot: simply double-click one of the braces to highlight the closure, delete, and run the test.
- Inline snapshotting's `assertInlineSnapshot` testing tool is fully customizable so that you can build your own testing helpers on top of it without your users even knowing they are using snapshot testing. In fact, we do this to create a testing tool that helps us test the Swift code that powers [Point-Free](https://www.pointfree.co). It's called [`assertRequest`][assert-request-gh], and it allows you to simultaneously assert the request being made to the server (including URL, query parameters, headers, POST body) as well as the response from the server (including status code and headers).
For example, to test that when a request is made for a user to join a team subscription, we can [write the following][assert-request-example]:
```swift
await assertRequest(
connection(
from: request(
to: .teamInviteCode(.join(code: subscription.teamInviteCode, email: nil)),
session: .loggedIn(as: currentUser)
)
)
)
```
And when we first run the test it will automatically [expand][assert-request-example]:
```swift
await assertRequest(
connection(
from: request(
to: .teamInviteCode(.join(code: subscription.teamInviteCode, email: nil)),
session: .loggedIn(as: currentUser)
)
)
) {
"""
POST http://localhost:8080/join/subscriptions-team_invite_code3
Cookie: pf_session={"userId":"00000000-0000-0000-0000-000000000001"}
"""
} response: {
"""
302 Found
Location: /account
Referrer-Policy: strict-origin-when-cross-origin
Set-Cookie: pf_session={"flash":{"message":"You now have access to Point-Free!","priority":"notice"},"userId":"00000000-0000-0000-0000-000000000001"}; Expires=Sat, 29 Jan 2028 00:00:00 GMT; Path=/
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
"""
}
```
This shows that the response redirects the use back to their account page and shows them the flash message that they now have full access to Point-Free. This makes writing complex and nuanced tests incredibly easy, and so there is no reason to not write lots of tests for all the subtle edge cases of your application's logic.
* Added: DocC documentation (#765). The `SnapshotTesting` and `InlineSnapshotTesting` are fully documented using DocC.
* Infrastructure: swift-format support (#765). The library is now auto-formatted using swift-format.
**Full Changelog**: https://github.com/pointfreeco/swift-snapshot-testing/compare/1.12.0...0.13.0
[assert-request-gh]: https://github.com/pointfreeco/pointfreeco/blob/5b5cd26d8240bd0e1afb77b7ef342458592c7366/Sources/PointFreeTestSupport/PointFreeTestSupport.swift#L42-L87
[assert-request-example]: https://github.com/pointfreeco/pointfreeco/blob/a237ce693258b363ebfb4bdffe6025cc28ac891f/Tests/PointFreeTests/JoinMiddlewareTests.swift#L285-L309
## What's Changed
* Added: `assertSnapshot(of:)` is now the default interface for snapshot assertions (https://github.com/pointfreeco/swift-snapshot-testing/pull/762). `assertSnapshot(matching:)` will remain in 1.x as a soft-deprecated alias.
* Infrastructure: Add to README plug-ins (thanks @BarredEwe, https://github.com/pointfreeco/swift-snapshot-testing/pull/746; @tahirmt, https://github.com/pointfreeco/swift-snapshot-testing/pull/763).
* Infrastructure: Don't ignore Package.resolved (https://github.com/pointfreeco/swift-snapshot-testing/pull/649).
## New Contributors
* @BarredEwe made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/746
**Full Changelog**: https://github.com/pointfreeco/swift-snapshot-testing/compare/1.11.1...1.12.0
## What's Changed
* Fixed: Xcode 15 support (thanks @finestructure, https://github.com/pointfreeco/swift-snapshot-testing/pull/737).
* Infrastructure: Add PreviewSnapshots to README "Plug-ins" (thanks @jflan-dd, https://github.com/pointfreeco/swift-snapshot-testing/pull/696)
**Full Changelog**: https://github.com/pointfreeco/swift-snapshot-testing/compare/1.11.0...1.11.1
## What's Changed
* Added: Image paths in Xcode XCTest output are now clickable (thanks @RufusMall, https://github.com/pointfreeco/swift-snapshot-testing/pull/675).
* Fixed: Silenced SPM warnings by excluding snapshots and fixtures in Package manifest (thanks @valeriyvan, https://github.com/pointfreeco/swift-snapshot-testing/pull/684).
* Fixed: 1.10.0 erroneously bumped platform requirements. This release reverts compatibility to align with previous versions (https://github.com/pointfreeco/swift-snapshot-testing/pull/698).
* Infrastructure: Fixed Ubuntu CI by locking version (https://github.com/pointfreeco/swift-snapshot-testing/pull/685).
## New Contributors
* @RufusMall made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/675
**Full Changelog**: https://github.com/pointfreeco/swift-snapshot-testing/compare/1.10.0...1.11.0
## Changes that may affect your build requirements
- The package name has been changed from `SnapshotTesting` to `swift-snapshot-testing`, to better reflect community naming conventions (https://github.com/pointfreeco/swift-snapshot-testing/pull/555). This may require you to update any `Package.swift` files that depend on Snapshot Testing.
- Support for CocoaPods and Carthage has been obsoleted. No new releases will be available on those platforms, starting with 1.10.0. Please use the Swift Package Manager to depend on Snapshot Testing.
- Snapshot Testing now requires Swift 5.5+, as well at iOS 13+, macOS 10.15+, tvOS 13+, and watchOS 6+.
## Changes that may affect snapshot format/output
> **Warning**: The following updates change how a strategy may output a snapshot, causing existing snapshot suites to fail. When upgrading, please rerecord your failing snapshots and audit the changes.
- Fixed: A UIViewController strategy was not passing along the correct trait collection (thanks @arnopoulos, https://github.com/pointfreeco/swift-snapshot-testing/pull/554).
- Fixed: iPhone XS Max portrait configuration was not applying base traits (thanks @imvm, https://github.com/pointfreeco/swift-snapshot-testing/pull/417)
- Fixed: URLRequest strategy now sorts query items for more consistent diffing (thanks @mihai8804858, https://github.com/pointfreeco/swift-snapshot-testing/pull/491).
- Removed: GLKView is no longer supported (thanks @jpsim, https://github.com/pointfreeco/swift-snapshot-testing/pull/507).
## Everything else
- Added: Image-based strategies have a new `perceptualPrecision` option, which can be used to support snapshot tests across Intel and M1 devices. Along for the ride is a 90+% speed improvement to the strategies (thanks @ejensen, https://github.com/pointfreeco/swift-snapshot-testing/pull/628).
- Added: Windows support, CI (thanks @MaxDesiatov, https://github.com/pointfreeco/swift-snapshot-testing/pull/532).
- Added: Failure messages now include the snapshot name, if given (thanks @calda, https://github.com/pointfreeco/swift-snapshot-testing/pull/547).
- Added: iPhone 13 configs (thanks @luispadron, https://github.com/pointfreeco/swift-snapshot-testing/pull/603).
- Added: iPad 9.7" and iPad 10.2" configs (thanks @skols85, https://github.com/pointfreeco/swift-snapshot-testing/pull/405).
- Added: iPhone 12 and iPhone 12 Pro Max configs(thanks @imvm, https://github.com/pointfreeco/swift-snapshot-testing/pull/418).
- Added: `Snapshotting.json` for `Any` value (thanks @NachoSoto, https://github.com/pointfreeco/swift-snapshot-testing/pull/552).
- Added: Newly-recorded snapshots are now attached to the test run (thanks @marcelofabri, https://github.com/pointfreeco/swift-snapshot-testing/pull/586).
- Fixed: the UIImage strategy was using the device scale instead of the scale of the given images (thanks @codeman9, https://github.com/pointfreeco/swift-snapshot-testing/pull/472).
- Fixed: the UIImage strategy now compares image contexts using the same colorspace (thanks @dflems, https://github.com/pointfreeco/swift-snapshot-testing/pull/446).
- Fixed: the WebView strategy no longer overrides the delegate (thanks @teameh in https://github.com/pointfreeco/swift-snapshot-testing/pull/443).
- Fixed: Patched a leak when running tests in a host application (thanks @llinardos, https://github.com/pointfreeco/swift-snapshot-testing/pull/511).
- Fixed: False positive when asserting reference image with empty image (thanks @nuno-vieira, https://github.com/pointfreeco/swift-snapshot-testing/pull/453).
- Fixed: watchOS compilation (thanks @aydegee, https://github.com/pointfreeco/swift-snapshot-testing/pull/579).
- Fixed: Support for repeatedly running tests (thanks @krzysztofpawski, https://github.com/pointfreeco/swift-snapshot-testing/pull/585).
- Infrastructure: Add `swift-snapshot-testing-stitch` to plugins list (thanks @Sherlouk, https://github.com/pointfreeco/swift-snapshot-testing/pull/483)
- Infrastructure: Document diff tool configuration.
- Infrastructure: README updates (thanks @MaatheusGois, @gohanlon), documentation fixes (thanks @heckj, @valeriyvan).
- Infrastructure: Added GitHub issue templates (https://github.com/pointfreeco/swift-snapshot-testing/pull/556).
- Infrastructure: Add SnapshotTestingHEIC to plugins list (thanks @alexey1312, https://github.com/pointfreeco/swift-snapshot-testing/pull/561).
## New Contributors
* @arietis made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/468
* @codeman9 made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/472
* @Nikoloutsos made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/482
* @mihai8804858 made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/491
* @dflems made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/446
* @skols85 made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/405
* @imvm made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/418
* @teameh made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/443
* @MaatheusGois made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/496
* @calda made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/547
* @MaxDesiatov made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/532
* @jpsim made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/507
* @arnopoulos made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/554
* @llinardos made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/511
* @heckj made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/601
* @aydegee made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/579
* @valeriyvan made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/630
* @ejensen made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/628
* @luispadron made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/603
* @alexey1312 made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/561
* @gohanlon made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/592
* @marcelofabri made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/586
* @nuno-vieira made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/453
* @krzysztofpawski made their first contribution in https://github.com/pointfreeco/swift-snapshot-testing/pull/585
**Full Changelog**: https://github.com/pointfreeco/swift-snapshot-testing/compare/1.9.0...1.10.0
- Added: publicized `data` snapshotting strategy (thanks @regexident).
- Speed up `NSImage` comparison (thanks @finestructure, @JaapWijnen).
- Fixed: enabled testing search paths (thanks @thedavidharris).
- Infrastructure: links for AccessibilitySnapshot and AccessibilitySnapshotColorBlindness (thanks @Sherlouk).
- Rename `SnapshotTesting.record` to `SnapshotTesting.isRecording` to avoid clash with XCTestCase's new `record` method (thanks @xavierLowmiller).
- Fix UIApplication selector to return the application as expected (thanks @mstultz).
- Fix key window warning (thanks @tinder-maxwellelliott)
- Change minimum iOS version from iOS 10 to 11 to fix SwiftUI linking problems (thanks @thedavidharris).
- Added: SwiftUI support (thanks @natemann, @regexident).
- Added: Apple TV 4K support (thanks @reez).
- Added: Mac Catalyst support (thanks @rjchatfield).
- Added: UIBezierPath, NSBezierPath, CGPath strategies (thanks @regexident).
- Improved: don't crash on empty images, instead produce error artifact (thanks @mackoj).
- Bug fixed: trait collection now passed to view controller's recursive description strategy (thanks @erikpoort).
- Bug fixed: will no longer crash on hidden/unloaded web views (thanks @stuaustin).
- Bug fixed: don't re-add view controller to window when already added (thanks @hassfers).
- More test coverage (thanks @SatoTakeshiX, @sidepelican).
- Typos fixed (thanks @freak4pc, @jstart).
- Other improvements: timeout error messaging, installation instructions, troubleshooting instructions, Linux CI.
Xcode 11.4 Support
3 years ago
This release fixes a bug introduced in the Xcode 11.4 beta with SPM and Swift 5.2.