Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been leading the adoption of vitest at my company. It's not perfect, and there are some bugs but the performance gain is truly incredible. We have about 150 snapshots for various UI components and vitest can crunch through all of them in about 5 seconds, whereas it would take Jest 3-4X that time.

It's also nice if you're running a "vite stack", you don't have to pull in babel and a bunch of other libs just to make Jest work.



Do you feel the snapshot tests are useful? I've mostly had bad experiences with them (mostly noise), so interested in hearing what makes them work for you/others.


I (weirdly) got sold on snapshot tests while developing a tree-sitter grammar. They don’t make it super obvious (and most snapshotting test solutions don’t) that you can “update all”, but the workflow makes more sense to me now that I’ve even generated my test cases from a more intentional suite. The goal is for it to be noise! It’s entirely a regression test, and it should alert you if you changed something without knowing you did. But it’s only valuable if you snapshot test the things you expect to be stable, write specific tests for the changes you intend to make, and compare between them.


Their not that terribly useful. We have already been talking about replacing them with proper unit tests. One thing they are very useful for is being a cheap way of showing non-technical leadership that you have "100% test coverage".


I only have a handful of Jest unit tests, but they each take nearly 30 seconds nowadays and I don't really know why. Maybe because everything is wrapped in a Formik top level tag? Maybe it somehow pulls in and executes all my code multiple times over? There's probably something silly going on there.

Anyway as just the one developer on this project, I don't see the value in writing unit tests for every one of my components. They just work, I'll leave them alone for a few years until someone else builds a new UI.


That’s awesome news. Started looking it integrating jest today but we use vite, so this is a very timely post!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: