Open mayank99 opened 1 year ago
I cloned down and got vitest hooked up quite easily - running vite directly, compiling and comparing snapshots.
Some problems with testing like this:
hey, thanks for looking into this!
- Vite plugins don't get picked up by the optional esbuild processing when it hits a template literals.
this might be possible to work around by using a real file instead of virtual file. since you're running vite.build
, it should know how to read the file system so you could create a small vite app and build that.
- Can't test the CSS itself and how it's applied
hmm... i think you should be able to read the CSS file produced after vite.build
and check its contents?
- Nested and escaped back-ticks don't look great for easily reading a test, especially when you add template literals.
this should be partly solved by reading a real project.
currently there is no testing strategy, making it extremely easy for things to break 😳
options to consider:
vitest
- the obvious one, it would be easy to set up, but it's kinda fake as it won't run in the browser.playwright
- this runs in a real browser and has built-in support for screenshots. there is experimental vite support.