3 ms·
If I know mocha is there any reason I should learn and use jest? (outside of a React project)
by jmull 4y ago
If I know mocha is there any reason I should learn and use jest?
(outside of a React project)
- FinalBriefing 4y agoI found it to be fast and easy to set up. I reviewed a number of testing frameworks for vanilla JS projects, and it came up on top, even though I hoped it wouldn't (I try to avoid all Facebook products). I can't remember the specifics, but I think it was a mix of having nice reporting built in, easy to spy on or mock our ESModules, and there are a lot of other developers using it, so it was easy to find solutions. It mostly "just worked" and didn't require adding other libraries to handle mocks and spies.
- no_wizard 4y agoIf you don't plan on using it in the browser, it has everything Mocha does and doesn't, like built in expect functions (mocha only provides the runner infrastructure). Its also, as of late, really shown some innovation around testing, I think Jest 28 is a huge step in the right direction. The only other fully fledged alternative I can think of is Jasmine (which, iirc Jest is actually a fork of?) but Jasmine isn't as well maintained and has no transform infrastructure. Basically, unless you're just really happy with mocha, I think Jest gives you more flexibility, especially as projects / products grow overtime. Jest is also better in monorepos IMO.