Add childCountScreenshotTest: screenshot after waiting for children to mount#114
Open
EmilioBejasa wants to merge 6 commits into
Open
Add childCountScreenshotTest: screenshot after waiting for children to mount#114EmilioBejasa wants to merge 6 commits into
EmilioBejasa wants to merge 6 commits into
Conversation
…ith view.post check - Remove ViewHelpers from constructViewTest and childCountTest (IsolatedTest.kt) and testSimpleTextView (ScreenshotTest.kt); use explicit measure()/layout() calls - Replace 30s poll loop in childCountTest with a self-rescheduling Runnable posted via view.post(), driven by the main-thread Handler that WindowAttachment.dispatchAttach installs in AttachInfo; block test thread on CompletableFuture.get(5s) - Remove childCountScreenshotTest (duplicate of childCountTest + screenshot) - assertGoodTask now captures and awaits startTask so the bg executor is drained before the future is polled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…o mount Uses the same view.post polling mechanism as childCountTest to wait for Fabric to mount children before snapping the screenshot, ensuring the result is never blank. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
tdrhq
requested changes
Apr 13, 2026
| val view = surface.view!! as ViewGroup | ||
| var detacher: WindowAttachment.Detacher? = null | ||
| var startTask: TaskInterface<Void>? = null | ||
| val childrenMounted = CompletableFuture<Unit>() |
Contributor
There was a problem hiding this comment.
this is still using concurrency to coordinate between the threads.
| val check = object : Runnable { | ||
| override fun run() { | ||
| if (view.childCount > 0) childrenMounted.complete(Unit) | ||
| else view.postDelayed(this, 50) |
Contributor
There was a problem hiding this comment.
this is just a different way of writing the previous loop
The previous version duplicated childCountTest's CompletableFuture coordination and view.postDelayed polling. Use prerender()+start() directly, matching the pattern of constructViewTest. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
One runOnMainSync for all setup + start(). waitUntil polls until children are mounted (exits immediately on success, 5s timeout), replacing the CompletableFuture + postDelayed loop from childCountTest. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use dispatchAttach + onHostResume + waitUntil so Fabric mounts children before the screenshot is taken. Previously the screenshot was blank. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Stacked on #113.
Adds
childCountScreenshotTesttoIsolatedTest: the sameview.postpolling mechanism fromchildCountTestis used to wait for Fabric to mount children before callingScreenshot.snap(). This guarantees the screenshot is never blank.The screenshot is taken on the test thread (not inside
runOnMainSync) so the JUnit runner context is intact and the file is named correctly.Recorded result: renders "Hello" as expected.
Test plan
childCountScreenshotTestpassesrecordDebugAndroidTestScreenshotTestproduces a non-blank screenshot namedcom.rnstorybookautoscreenshots.IsolatedTest_childCountScreenshotTestverifyDebugAndroidTestScreenshotTestpasses🤖 Generated with Claude Code