Open jonrimmer opened 3 years ago
We are using the new jsx runtime using vite-react-jsx, but this causes an error when we run tests. I have reproduced it here: https://github.com/jonrimmer/vite-jest/tree/problem-jsx
The app runs fine when I run pnpnm dev, but when I run pnpm jest:unit on react-app-ts example, I get an error saying React is not defined...
pnpnm dev
pnpm jest:unit
react-app-ts
React
FAIL src/App.test.tsx ✕ renders learn react link (52 ms) ● renders learn react link ReferenceError: React is not defined 7 | const [count, setCount] = useState(initial); 8 | > 9 | return ( | ^ 10 | <div className={styles.app}> 11 | <header className={styles.appHeader}> 12 | <img src={logo} className={styles.appLogo} alt="logo" /> at App (src/App.tsx:9:3) at Object.<anonymous> (src/App.test.tsx:5:3) console.error Error: Uncaught [ReferenceError: React is not defined]
...but the React import should be automatically added when I am using vite-react-jsx.
vite-react-jsx
We are using the new jsx runtime using vite-react-jsx, but this causes an error when we run tests. I have reproduced it here: https://github.com/jonrimmer/vite-jest/tree/problem-jsx
The app runs fine when I run
pnpnm dev
, but when I runpnpm jest:unit
onreact-app-ts
example, I get an error sayingReact
is not defined......but the React import should be automatically added when I am using
vite-react-jsx
.