Addition of the delay
Parameter in the image
for Controlled Delay Snapshot
#973
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Detected
The existing
wait
method in the SnapshotTesting library is designed to pause test execution for a period before starting snapshot capture. However, this behavior does not allow asynchronous operations (such as animations, ViewModel requests, or UI updates) to complete during the waiting period. This limits critical integration testing scenarios where it is necessary to:The
wait
method simply pauses the test before starting, not allowing UI interaction during the waiting period.Implemented Solution
I added a new
delay
parameter to theimage
method to allow snapshot capture to occur after a controlled delay, during which the UI continues to render normally. This:delay
parameter is optional (nil
by default), preserving existing functionality.image
without altering the library's main structure.How It Works
delay
) after rendering begins.Usage Example
Benefits
image
behavior whendelay
is not specified.Difference between
wait
anddelay
wait
(Existing)delay
(New Contribution)Impact on the Library
delay
parameter is optional and preserves the existingimage
signature.image
for advanced scenarios without altering the library's main logic.This contribution addresses a critical gap in integration testing and offers additional flexibility to SnapshotTesting users.