Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using vite-react-jsx #9

Open
jonrimmer opened this issue Jul 13, 2021 · 0 comments
Open

Error when using vite-react-jsx #9

jonrimmer opened this issue Jul 13, 2021 · 0 comments

Comments

@jonrimmer
Copy link

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...

 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.

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

No branches or pull requests

1 participant