Skip to content

Add a closure that runs just before the snapshot is taken.#1055

Open
maxchuquimia wants to merge 1 commit intopointfreeco:mainfrom
maxchuquimia:add-preparation-closure
Open

Add a closure that runs just before the snapshot is taken.#1055
maxchuquimia wants to merge 1 commit intopointfreeco:mainfrom
maxchuquimia:add-preparation-closure

Conversation

@maxchuquimia
Copy link
Copy Markdown

When snapshotting with SwiftUI, we wanted to wait for onAppear of the snapshotted view to be called before taking the snapshot (as in some cases the final state of the view was not yet ready until then). We also wanted a way to wait until our own dispatch manager had reported no Tasks were still running (and therefore the view models had published the final state of the SwiftUI view).

By adding a closure that gets called between layout and the snapshot being taken, we can use our existing test infrastructure to wait for said expectations and therefore ensure the captured snapshot properly reflects the state of a fully set up view.

When snapshotting with SwiftUI, we wanted to wait for onAppear of the
snapshotted view to be called before taking the snapshot as in some
cases the final state of the view was not yet ready until then. We also
wanted a way to wait until our own dispatch manager had reported no
Tasks were still running (and therefore the final view state had been
published).

By adding a closure thats called between layout and the snapshot being
taken, we can use our existing test infrastructure to wait for said
expectations to ensure the snapshot properly reflects the state of a
fully set up view.
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.

1 participant