Recently, I have been learning to write some tests in React using Jest and RTL(React Testing Library), which has been a fun and eye-opening adventu...
For further actions, you may consider blocking this person and/or reporting abuse
Thank for the article! Guys if you're getting an error:
"Cannot use JSX unless the '--jsx' flag is provided" then I hope this might help you(worked for me):
I am using Vite + React + TypeScript + Jest. I deleted tsconfig.app.json (comes out of the box) and tsconfig.node.json. So it's only tsconfig.json(code below). And it solved my problem with imports and jsx.
Great post, it's definitely not straightforward to setup unit testing for a React + Vite project. I recently wrote a similar article on this as well; it covers how to setup vitest, RTL, Husky, ESLint & Prettier.
Thanks Rajae. Will definitely checkout your article.
I have fixed my issue by adding and pinning the versions of jest-environment and jest-config to the same version as jest.
"identity-obj-proxy": "^3.0.0",
"jest": "^27.5.1",
"jest-environment-jsdom": "^27.5.1",
I get this error when i try to run tests :(
don't know how to fix this, i've already tried everything :/
try to remove offensive words should help!
This was really helpful for me. Thanks!
Thank you, it's working. I got ts error, but after adding "esModuleInterop": true in tsconfig.json it went away.
no fluffs and straight to the point, cheers mate!
Thanks! this was a huge time saver
I am happy you found it useful Isaac. :)
it is really good! Saved a lot of time. Thank you so much