Web trace screenshots can cause React hydration warnings by hiding carets with inline styles · Issue #1259 · tester-army/e2e · GitHub
Skip to content

Web trace screenshots can cause React hydration warnings by hiding carets with inline styles #1259

Description

@roderik

@e2e-dev/web 0.15.2 automatically captures a trace screen after app.open() finishes navigation. On a server-rendered React page, this can precede hydration. capturePixels() passes caret: 'hide' to Playwright, which temporarily changes input and textarea inline styles. React then reports a hydration mismatch even though the application rendered matching HTML.

Reproduction:

  1. Enable trace: 'on' with the web engine and navigate from a loaded page to an SSR React form using app.open().
  2. Attach console/page-error listeners before navigation. Hydration must still be pending when the automatic trace screenshot starts; a scenario's subsequent hydration wait cannot prevent that capture.
  3. Observe the warning below. The same navigation without the automatic capture does not warn.

Sanitized trace:

PlaywrightSurface.open -> acted -> TraceFeed.screenAfterAction
  -> captureObservation -> capturePixels
  -> page.screenshot({ animations: 'disabled', caret: 'hide', ... })

A tree hydrated but some attributes of the server rendered HTML didn't match the client properties.
  <Input>
    <input id="instrument-wizard-basics-name" ...>
-     style={{caret-color:"transparent"}}
  <Textarea>
    <textarea id="instrument-wizard-basics-description" ...>
-     style={{caret-color:"transparent"}}

Suggested fix: use caret: 'initial' with Playwright's temporary screenshot stylesheet (style: '* { caret-color: transparent !important; }'). This keeps carets out of captured pixels without editing React-owned form attributes. Secure-field masks and trace capture remain enabled. Alternatively, expose a supported pre-capture readiness hook.

Our browser fixture asserts that the navigation emits no console or page errors; the original package fails that assertion. With the stylesheet change, the same fixture and its session setup passed (2 tests, 19 seconds, zero console/page errors), with tracing and secure-field masks still enabled.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions