feat: PER-7348 add waitForReady() call before serialize()#308
Merged
Conversation
Adds the readiness gate from percy/cli#2184. New waitForReady() helper runs PercyDOM.waitForReady via executeAsyncScript (callback signal) before the existing PercyDOM.serialize executeScript inside getSerializedDOM. Diagnostics are attached to the mutable snapshot as readiness_diagnostics. serialize is unchanged. Config precedence: options['readiness'] > cliConfig.snapshot.readiness > empty. Backward compat via in-browser typeof guard. Disabled preset short-circuits. Graceful on exception. Visibility: getSerializedDOM is now package-private so tests can call it directly; it was previously private. Tests (Mockito): diagnostics attached + readiness script contains waitForReady, disabled preset skips executeAsyncScript, readiness throw leaves serialize intact. Local: mvn test → 3 passed, 0 failed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Replaced exclusive precedence (`else if`) with shallow-merge in a new `resolveReadinessConfig()` helper. Per-snapshot keys win, global keys inherited — a partial per-snapshot override no longer silently drops a global `preset: disabled` kill switch. - Set driver script timeout to match `readiness.timeoutMs` (+ 2s buffer) around the executeAsyncScript call, with finally-restore. WebDriver's default ~30s script timeout was silently capping higher user-configured readiness timeouts via ScriptTimeoutException. - Strip `readiness` from `buildSnapshotJS` (so it doesn't leak into PercyDOM.serialize args) and from `postSnapshot` JSON (so it doesn't round-trip to the CLI which already has it via healthcheck). `mvn compile` passes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CLI 1.31.15-beta.0 ships PercyDOM.waitForReady (the readiness gate). The SDK changes in this PR call waitForReady end-to-end in tests; old CLI pins (1.30.9, 1.31.10) don't have it, causing the typeof guard's done() callback path to never quite settle in geckodriver's async-script handling. Bump so tests run against a CLI that actually has the feature.
rishigupta1599
approved these changes
May 25, 2026
Shivanshu-07
added a commit
that referenced
this pull request
May 27, 2026
Bump version to 2.2.1-beta.0 to ship the readiness gate (waitForReady before serialize, PER-7348) merged in #308. Co-authored-by: Claude Opus 4.7 (1M context) <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
Adopts the readiness gate from percy/cli#2184 (PER-7348). New
waitForReady(jse, options)helper runsPercyDOM.waitForReadyviaexecuteAsyncScript(callback signal) before the existing serializeexecuteScriptinsidegetSerializedDOM. Diagnostics are attached toreadiness_diagnosticson the snapshot. Serialize is unchanged.Contract
options["readiness"]→cliConfig.snapshot.readiness→ empty (CLIbalanceddefault).typeof PercyDOM.waitForReady === 'function'guard.Visibility
getSerializedDOMis now package-private (wasprivate) so tests can call it directly.Tests
3 new Mockito tests in
SdkTest:waitForReadyTest results
mvn test -Dtest=...)Related