S
SolidJS•17mo ago
Nyantastic

Testing SolidStart routes with Vitest

Hello! I'm using SolidStart and Vitest to test the components. But I didn't manage to find a way to test the route files (such as the index.tsx in my route folders, or the dynamic ones [id].tsx for example). I'm putting my test files.test.tsx next to the tested files, and the route ones kinda broke my app's routes. Do I necessarily have to move them somewhere else? And then, any idea on how I should render and test my routes? Does anyone has an example of good practices to test a SolidStart route? Thanks a lot for your help, I'm apologize if the questions are a bit stupid. I wish you a nice day!
3 Replies
Alex Lohr
Alex Lohr•17mo ago
There are no stupid questions. Unfortunately, jsdom's support for location is very limited, thus it is somewhat difficult to test from a URL perspective. It is possible to set up a router with source={staticIntegration} so it is not bound to the location. I guess that will soon be the recommended way of testing, but I still need to test and document this.
Nyantastic
Nyantastic•17mo ago
Thank you so much for your fast answer! I really appreciate it 😄
Alex Lohr
Alex Lohr•17mo ago
If you run into problems, please ping me, so I can participate in your learning experience to improve the documentation.