Skip to content

Add display scale param to public functions #9

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

Merged
merged 2 commits into from
Jul 8, 2025
Merged

Conversation

olejnjak
Copy link
Member

@olejnjak olejnjak commented Jun 9, 2025

Summary

In some situations like components with very tight layout it might be useful to test how it will look on various display scales, so it is good to be able to override displayScale from init in assert call.

In such cases as attached, every pixel counts
Screenshot 2025-06-10 at 12 56 24

Author checklist

@olejnjak olejnjak requested review from komkovla and Copilot June 9, 2025 15:35
@olejnjak olejnjak self-assigned this Jun 9, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an optional displayScale override to snapshot assertions, allowing tests to specify a custom display scale when rendering SwiftUI snapshots.

  • Added a displayScale: CGFloat? = nil parameter to all public assertSnapshot variants
  • Updated internal trait-building logic to prefer the override (scaleParam) over the stored displayScale
  • Documented the new parameter in the CHANGELOG.md

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sources/AckeeSnapshots/SnapshotTest.swift Added displayScale parameter to public/assert methods and updated internal calls to apply it
CHANGELOG.md Added entry for displayScale under Next and reorganized release notes
Comments suppressed due to low confidence (3)

Sources/AckeeSnapshots/SnapshotTest.swift:277

  • [nitpick] The internal parameter name scaleParam is ambiguous alongside the displayScale property; consider renaming it to something like overrideDisplayScale for clarity.
displayScale scaleParam: CGFloat?,

Sources/AckeeSnapshots/SnapshotTest.swift:294

  • New behavior for overriding displayScale should be covered by unit tests or snapshot tests to ensure the override is applied correctly in all layout variants.
(scaleParam ?? displayScale).map { .init(displayScale: $0) },

CHANGELOG.md:3

  • [nitpick] The placeholder instruction still reads generically; consider clarifying or removing this line to match the rest of the formatted changelog.
please enter new entries in format, new entries on top

@olejnjak olejnjak merged commit 825aff4 into main Jul 8, 2025
1 check passed
@olejnjak olejnjak deleted the display-scale-param branch July 8, 2025 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants