DEV Community

Cover image for What's your favorite JS testing framework?
Madza
Madza

Posted on

What's your favorite JS testing framework?

Nowadays, the industry is dominated by agile development and tight deadlines. Manual unit testing can be complex and time-consuming, so it makes sense to rely on automated frameworks.

Some of the favorites include: Jest, Mocha, Jasmine, Karma.

Do you unit test your code and what's your favorite testing framework?

Discussion (22)

Collapse
ben profile image
Ben Halpern

We use Jest, and I've been pretty happy with it overall. I'm not so deep into this type of work any more, but every time I need something I find it easy enough to follow along with what I'm seeing in the files and/or find useful docs and guides.

Collapse
madza profile image
Madza Author

I still remember reading your post on the DEVs tech stack and I was impressed seeing all the pieces working together so well πŸ˜‰
Jest has proven itself as a solid framework, with lots of devs trusting it.
According to npmtrends:
Img stats

Collapse
ben profile image
Ben Halpern

We've since simplified the tech stack a little bit, but yes we have had a focus on maintaining a good test suite and having the tools that support stability as much as we can.

Collapse
peerreynders profile image
peerreynders • Edited

Slow Tests

The tests take long enough to run that developers don't run them every time they make a change to the system under test (SUT). They wait until the next coffee break or other interrupt before running them. Or, whenever they run the tests they walk around and chat with other team members (or play Doom or surf the Internet or ...)

i.e. your test runner shouldn't be part of the problem - that's why uvu exists.

Collapse
madza profile image
Madza Author

This is insightful, thanks πŸ‘πŸ˜‰

Collapse
mage_ai profile image
Mage

We use React on our frontend, so Jest and Enzyme are our preferred JS testing frameworks. Since these are quite popular, there are also a lot of great resources out there on using them, and Jest is even recommended in React's docs.

Collapse
ashoutinthevoid profile image
Full Name • Edited

I use tape for most purposes. Simple, lightweight, works as well today as it did years and years ago. It's also very similar to Rust's built-in test runner, so when I move between languages the context switch is that much lighter.

I also personally dislike the bdd test style (thus I wouldn't use a framework that only provides that option, assuming the choice is mine). Not for any technical reasons that actually matter, just personal taste. So much noise for the same results.

Collapse
madza profile image
Madza Author

Thanks for the input πŸ‘πŸ˜‰

Collapse
siddharthshyniben profile image
Siddharth

Jest for now, though I'm building my own!

I try to build my own <everything>. I'm building my own framework, my own ghost, my own programming language, etc.

Collapse
madza profile image
Madza Author

Awesome to hear, best of luck in you projects πŸ‘πŸ˜‰

Collapse
fredericbonnet profile image
FrΓ©dΓ©ric Bonnet

For unit tests my favorite combo is Mocha/Chai, plus Sinon if I need mocks (though it's rarely the case for unit testing). For dev E2E I'm a big fan of CodeceptJS, far superior to Cypress IMHO.

Collapse
madza profile image
Madza Author

Thanks for the insight πŸ™β€

Collapse
knopkem profile image
Michael Knopke

Cypress. But only for frontend testing (integration testing is awesome), jest for backend, nodejs testing.

Collapse
madza profile image
Madza Author

Oh, yeah, heard about that too πŸ˜‰πŸ‘

Collapse
vonheikemen profile image
Heiker

ava is the one I like the most. Very similar to tape but adds some convenient features.

Collapse
madza profile image
Madza Author

Thanks for the input πŸ™β€

Collapse
joelbonetr profile image
JoelBonetR

The QA dept. πŸ˜‚πŸ˜‚πŸ˜‚

Collapse
madza profile image
Madza Author

Haha, made my day πŸ˜„πŸ˜„

Collapse
andrewbaisden profile image
Andrew Baisden

Jest, Enzyme, React Testing Library and Cypress.

Collapse
madza profile image
Madza Author

Thanks for the input πŸ™β€

Collapse
jcubic profile image
Jakub T. Jankiewicz • Edited

I use Jest and Ava, Ava was the only framework that allow async tests loading, so it was the only option for my Scheme interpreter.

Collapse
madza profile image
Madza Author

Thanks for the input πŸ™β€