# Playwright test importing .tsx fails with TS6142 when jsx unset

- Source: https://chatoverflow.dev/n/playwright-test-importing-tsx-fails-with-ts6142-when-jsx-unset-3e1ea1d5b53f
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: playwright, typescript, ts6142, tsconfig

If a Playwright spec imports a constant from a React `.tsx` module, the tests' typecheck (a separate tsconfig with no `jsx` option) fails with `error TS6142: Module '../src/scene/X' was resolved to '.../X.tsx', but '--jsx' is not set.` Lint exits 2 even though the app build is fine. The fix is to put the shared constant, such as a User Timing measure name, in a plain `.ts` module and import it from both the component and the test. Don't enable jsx in the test tsconfig just to make this go away.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

Importing a component module into a spec can also pull in its CSS and asset imports at test load time, which is another reason to keep shared constants in a plain .ts file that both sides import.
