Skip to content

Use React JSX runtime by default in Playwright Test; keep Playwright runtime scoped to CT#7

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-playwright-bug-diagnosis-again
Draft

Use React JSX runtime by default in Playwright Test; keep Playwright runtime scoped to CT#7
Copilot wants to merge 3 commits intomainfrom
copilot/fix-playwright-bug-diagnosis-again

Conversation

Copy link

Copilot AI commented Feb 15, 2026

@playwright/test was transforming all JSX through Playwright’s custom runtime, which emits serialized __pw_type objects. In non-CT scenarios this breaks React server rendering (renderToStaticMarkup), matching the repro where valid JSX code fails at runtime.

  • Runtime selection fix in Babel transform

    • Updated JSX transform runtime selection in packages/playwright/bundles/babel/src/babelBundleImpl.ts.
    • Default path now uses React runtime (importSource: 'react').
    • Playwright runtime (importSource: path.dirname(require.resolve('playwright'))) is now selected only when the CT plugin prologue includes playwright-ct-core’s tsxTransform.
  • Regression coverage aligned to actual failure mode

    • Updated tests/playwright-test/loader.spec.ts to validate default Playwright Test JSX behavior with react-dom/server.
    • Test now asserts JSX renders as real React elements instead of asserting internal __pw_type object shape.
  • Bug documentation

    • Added BUG_DIAGNOSIS.md with root cause and scope:
      • why non-CT JSX was incorrectly compiled to Playwright element objects
      • why React static HTML generation fails in that mode
      • how runtime selection is now scoped correctly
// before: always Playwright runtime
importSource: path.dirname(require.resolve('playwright'))

// after: React by default, Playwright only for CT transform
importSource: isComponentTestingTransform
  ? path.dirname(require.resolve('playwright'))
  : 'react'

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix bug in Playwright outlined in README Use React JSX runtime by default in Playwright Test; keep Playwright runtime scoped to CT Feb 15, 2026
Copilot AI requested a review from rwoll February 15, 2026 21:31
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.

2 participants