There are 30+ testing frameworks listed on the node.js module list...
Which frameworks are most popular? And what are their pros and cons?
I'm looking for a framework that supports unit testing of code that has a lot of async callbacks (probably like most other node projects). Also, I'm looking for something rather simple and small than complex.
So far I've looked into:
What are the best Node. js unit testing frameworks? According to “The State of JavaScript 2021,” the most popular JavaScript testing frameworks and libraries in 2021 were Testing Library, Vitest, Jest, Cypress, Playwright, and Storybook. Rounding out the top ten are Puppeteer, Mocha, Jasmine, AVA, and WebdriverIO.
Jest is one of the most popular unit testing tools, for JavaScript in general and also for Node. js.
Jest was the most popular JavaScript unit testing framework in 2020. For web apps that are based on React, Jest is the preferred framework. Apart from React, Jest supports unit testing of Angular, VueJS, NodeJS, and others.
expresso and vows are the most popular options. Although there are many good options out there. Update: As of Nov./2011, Mocha is the successor to expresso, according to the Readme.md at the expresso repository. should.js is often used with Mocha to allow BDD-style assertions.
Whatever you choose, I recommend using gently to stub core or third party modules.
I use/maintain testosterone, a little testing framework that runs test on serial so you can abuse gently. Not so many people using it though.
Since March 2012 we've been using Nodeunit and haven't looked back. It's straightforward and easy to work with, it lets you choose between module-level and class-level fixtures (setup/teardown), it's got a reasonable set of built-in assertions, and its command-line tool is very flexible. Try combining it with nodemon, too.
We looked a Vows briefly but didn't want a whole new weird syntax for defining tests. All you need are assertions, fixtures, and a decent harness, and Nodeunit fits the bill perfectly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With