DEV Community

Minimal setup for Vite, React and Jest Integration

Rohit on December 01, 2023

Recently, I encountered a project where I needed to add test cases, and surprisingly, configuring the project with Vite presented challenges, despi...
Collapse
 
nickfane profile image
Nick Fane

Thanks for this article Rohit. It was very helpful and a lot more straight-forward than other's I've seen.

I'll just put my 2c in regarding

*Step 6: Making your test work with Styling such as csss|sass *

This is perfectly explained in your article, but I might suggest adding a note about some of the basic errors you might get with CSS imports without this, for instance

Image description

This was the error I dealt with before I added the mock/transform for CSS. This made me circle around the jest/babel config a bit until I realised the connection between the transform and the mock style file.

Cheers again! I am planning on writing an article on some testing practices that I think are useful, I will link your article as a source for how I got my react, vite, jest setup.

Collapse
 
riolio profile image
Rohit

Thanks Nick for liking the article and pointing out on how to make it better. Appreciate it.