[React] Configuring Vite on a React project with Jest
When I first migrated from
Vite, there were no issues when running the dev server. However, I ran into a lot of errors when running tests and using svgs in my React components.
Use this setup if you
React Testing Libraryand
jestfor writing tests
svgrto import svgs as a React Component
Here is the file structure we will end up getting at the end of the setup.
CRA by default generates a file named
src directory. This file has the below import statement. Feel free to leave it as is or delete it and create one yourself.
svgrMock.js file goes under
Migrating a Create React App (CRA) application to Vite
I had an existing app that was scaffolded using create react app (CRA) and extended with craco. CRA didn't support the…