{"id":681,"hash":"2fe1fb73563430d8091a16f3798c004467e11c68df2b543784897d1e0afb439f","pattern":"Vitest with React Testing Library &#39;Unexpected Token&#39;","full_message":"I'm using react with ViteJS and Vitest for testing. I have set up the config for vitest and the test setup file too as you can see in the screenshots below.\n\nvite.config.js\n\nsrc/test/setup.ts\n\nsrc/app/App.tsx\n\nsrc/app/App.spec.js\n\nhere's the error I'm getting:\n\nI found a lot of sources on similar issues about the topic but nothing I tried worked. I also followed the documentation for the vite config and a lot of articles too. Everyone is saying the same thing but I'm still getting this error for some reason.","ecosystem":"npm","package_name":"reactjs","package_version":null,"solution":"I used the same config with jest and it worked fine. But in this situation, I got stuck and then tried to rename the filename to .tsx or .jsx instead of .ts or .js. After that, I re-ran the test file and everything started working.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/74970340/vitest-with-react-testing-library-unexpected-token","votes":6,"created_at":"2026-04-19T04:51:28.858530+00:00","updated_at":"2026-04-19T04:51:28.858530+00:00"}