Skip to content

Commit

Permalink
upgrade-snapshot-tests-dependency-fix (#5)
Browse files Browse the repository at this point in the history
* fix

* re-enable perceptualPrecision

* wip

* 0.98->0.95

* precision

* try 0.98 for precision

* pass precision, percpetualPrecision as parameters

---------

Co-authored-by: Adrian Sergheev <[email protected]>
  • Loading branch information
adriansergheev and Adrian Sergheev authored Jan 17, 2024
1 parent 002558c commit de28e39
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Sources/DemoKitSnapshot/XCTestCase+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ extension XCTestCase {
public func snapshotTest(
demoable: any Demoable,
record: Bool = false,
// https://github.com/pointfreeco/swift-snapshot-testing/pull/628#issuecomment-1256363278
precision: Float = 0.98,
perceptualPrecision: Float = 0.98,
file: StaticString = #file,
line: UInt = #line
) {
Expand All @@ -50,8 +53,10 @@ extension XCTestCase {
performSnapshots(
viewController: viewController,
record: record,
testName: demoable.identifier,
testName: demoable.identifier,
tweakName: tweak.testName,
precision: precision,
perceptualPrecision: perceptualPrecision,
file: file,
line: line
)
Expand All @@ -61,6 +66,8 @@ extension XCTestCase {
viewController: viewController,
record: record,
testName: demoable.identifier,
precision: precision,
perceptualPrecision: perceptualPrecision,
file: file,
line: line
)
Expand Down Expand Up @@ -145,11 +152,12 @@ extension XCTestCase {
record: Bool,
testName: String,
tweakName: String? = nil,
precision: Float = 0.98,
perceptualPrecision: Float = 0.98,
file: StaticString,
line: UInt
) {
UIView.setAnimationsEnabled(false)
let subpixelThreshold: UInt8 = 5
let userInterfaceStyle: [UIUserInterfaceStyle] = [.light, .dark]

userInterfaceStyle.forEach { userInterfaceStyle in
Expand All @@ -165,7 +173,8 @@ extension XCTestCase {
matching: viewController,
as: .image(
on: device.imageConfig,
subpixelThreshold: subpixelThreshold,
precision: precision,
perceptualPrecision: perceptualPrecision,
traits: traits
),
named: name,
Expand Down

0 comments on commit de28e39

Please sign in to comment.