Skip to content

Add more information around drawHierarchyInKeyWindow #796

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions Sources/SnapshotTesting/Snapshotting/SwiftUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

/// A snapshot strategy for comparing SwiftUI Views based on pixel equality.
///
/// If you are using a host application we recommend that you set
/// `drawHierarchyInKeyWindow` to `true` to capture the most accurate
/// snapshots. Setting it to `false` can result in snapshots that don't look
/// exactly like your user interface. Examples we've seen are tab bars that
/// don't have the right color for their unselected tabs, lists that have
/// corner radii on every row instead of only on the top and bottom rows,
/// and rounded rectangles that have rendering artifacts.
///
/// - Parameters:
/// - drawHierarchyInKeyWindow: Utilize the simulator's key window in order to render
/// `UIAppearance` and `UIVisualEffect`s. This option requires a host application for your
Expand Down
8 changes: 8 additions & 0 deletions Sources/SnapshotTesting/Snapshotting/UIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

/// A snapshot strategy for comparing views based on pixel equality.
///
/// If you are using a host application we recommend that you set
/// `drawHierarchyInKeyWindow` to `true` to capture the most accurate
/// snapshots. Setting it to `false` can result in snapshots that don't look
/// exactly like your user interface. Examples we've seen are tab bars that
/// don't have the right color for their unselected tabs, lists that have
/// corner radii on every row instead of only on the top and bottom rows,
/// and rounded rectangles that have rendering artifacts.
///
/// - Parameters:
/// - drawHierarchyInKeyWindow: Utilize the simulator's key window in order to render
/// `UIAppearance` and `UIVisualEffect`s. This option requires a host application for your
Expand Down
20 changes: 20 additions & 0 deletions Sources/SnapshotTesting/Snapshotting/UIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@

/// A snapshot strategy for comparing view controller views based on pixel equality.
///
/// This strategy trades image accuracy for the flexibility to use this
/// strategy inside of framework and package test targets. This can result
/// in snapshots that don't look exactly like the user interface they are
/// snapshotting. Examples we've seen are tab bars that don't have the right
/// color for their unselected tabs, lists that have corner radii on every
/// row instead of only on the top and bottom rows, and rounded rectangles
/// that have rendering artifacts.
///
/// For more accurate snapshots use a host application for your tests with
/// the ``image(drawHierarchyInKeyWindow:precision:perceptualPrecision:size:traits:)``
/// method and pass `true` to the `drawHierarchyInKeyWindow` parameter.
///
/// - Parameters:
/// - config: A set of device configuration settings.
/// - precision: The percentage of pixels that must match.
Expand Down Expand Up @@ -44,6 +56,14 @@

/// A snapshot strategy for comparing view controller views based on pixel equality.
///
/// If you are using a host application we recommend that you set
/// `drawHierarchyInKeyWindow` to `true` to capture the most accurate
/// snapshots. Setting it to `false` can result in snapshots that don't look
/// exactly like your user interface. Examples we've seen are tab bars that
/// don't have the right color for their unselected tabs, lists that have
/// corner radii on every row instead of only on the top and bottom rows,
/// and rounded rectangles that have rendering artifacts.
///
/// - Parameters:
/// - drawHierarchyInKeyWindow: Utilize the simulator's key window in order to render
/// `UIAppearance` and `UIVisualEffect`s. This option requires a host application for your
Expand Down