Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add record mode to inline snapshots #809

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/InlineSnapshotTesting/AssertInlineSnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Foundation
/// - value: A value to compare against a snapshot.
/// - snapshotting: A strategy for snapshotting and comparing values.
/// - message: An optional description of the assertion, for inclusion in test results.
/// - isRecording: Whether or not to record a new reference.
/// - timeout: The amount of time a snapshot must be generated in.
/// - syntaxDescriptor: An optional description of where the snapshot is inlined. This parameter
/// should be omitted unless you are writing a custom helper that calls this function under
Expand All @@ -34,6 +35,7 @@ import Foundation
of value: @autoclosure () throws -> Value,
as snapshotting: Snapshotting<Value, String>,
message: @autoclosure () -> String = "",
record isRecording: Bool = isRecording,
timeout: TimeInterval = 5,
syntaxDescriptor: InlineSnapshotSyntaxDescriptor = InlineSnapshotSyntaxDescriptor(),
matches expected: (() -> String)? = nil,
Expand Down Expand Up @@ -114,7 +116,7 @@ import Foundation
)
return
}
guard let difference = snapshotting.diffing.diff(actual, expected)?.0
guard let difference = snapshotting.diffing.diff(expected, actual)?.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff felt backwards in the error message, so this should improve the readability.

else { return }

let message = message()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Re-run "testMySnapshot" to test against the newly-recorded snapshot.

### Essentials

- ``assertInlineSnapshot(of:as:message:timeout:syntaxDescriptor:matches:file:function:line:column:)``
- ``assertInlineSnapshot(of:as:message:record:timeout:syntaxDescriptor:matches:file:function:line:column:)``

### Writing a custom helper

Expand Down