Respect tsconfig jsxImportSource in JSX transformation#5
Draft
Respect tsconfig jsxImportSource in JSX transformation#5
Conversation
When a user's tsconfig.json specifies jsxImportSource or uses jsx: "react-jsx",
Playwright now honors that setting instead of always using its own JSX runtime.
This fixes the bug where React JSX in test files would produce Playwright's
internal {__pw_type: 'jsx', ...} objects instead of real React elements.
Co-authored-by: rwoll <[email protected]>
Co-authored-by: rwoll <[email protected]>
…ForFile Co-authored-by: rwoll <[email protected]>
Copilot
AI
changed the title
[WIP] Fix bug in Playwright as described in README
Respect tsconfig jsxImportSource in JSX transformation
Feb 15, 2026
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.
Playwright's babel transform hardcodes its own
jsx-runtimeas theimportSourcefor all JSX, ignoring the user'stsconfig.json. This means JSX in test files always produces{__pw_type: 'jsx', ...}descriptor objects instead of real React elements, breaking any code that passes JSX to React APIs likerenderToStaticMarkup().Changes
tsconfig-loader.ts— ParsejsxandjsxImportSourcefromcompilerOptions. Whenjsxisreact-jsx/react-jsxdevwith no explicitjsxImportSource, default to"react"(matching tsc behavior).transform.ts— AddjsxImportSourceForFile()to look up the configured JSX import source from tsconfig, include it in the compilation cache hash, and thread it through tobabelTransform.babelBundle.ts— ExtendBabelTransformFunctiontype with optionaljsxImportSource.babelBundleImpl.ts— Use user'sjsxImportSourcewhen present, fall back to Playwright's own JSX runtime otherwise:loader.spec.ts— Two new tests: explicitjsxImportSourcefrom tsconfig, and implicit defaulting viajsx: "react-jsx".BUG_DIAGNOSIS.md— Root cause analysis.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.