Vitest with React Testing Library 'Unexpected Token'
Full error 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. vite.config.js src/test/setup.ts src/app/App.tsx src/app/App.spec.js here's the error I'm getting: I 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.
Solutionsource: stackoverflow \u2197
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.
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/2fe1fb73563430d8091a16f3798c004467e11c68df2b543784897d1e0afb439fhash \u00b7 2fe1fb73563430d8091a16f3798c004467e11c68df2b543784897d1e0afb439f