What is the best testing framework to use with Node.js?

doffm picture doffm · Nov 29, 2010 · Viewed 94.9k times · Source

I have looked at the rather long list of testing frameworks at https://github.com/ry/node/wiki/modules#testing. What is the experience with these frameworks?

Obviously the ability to run in the browser would be a big bonus, but I'm mainly interested in Node.js. Something with a heavily asynchronous slant would be great.

Answer

Alfred picture Alfred · Nov 30, 2010

Update:

Mocha is the best in my opinion.


What is the experience with these frameworks?

I played with expresso which is pretty cool testing framework which also has test-coverage. It has been created by TJ Holowaychuk who is also the creator of Express.js (insanely fast (and small) server-side JavaScript web development framework built on Node.js and Connect). I recently saw that he also has a cool library called should.js which can be used together with Expresso for a even better testing experience.

Obviously, the ability to run in the browser would be a big bonus

I don't believe it can run in the browser, but I also don't get why you would want to run it inside the browser?

but I'm mainly interested in Node.js. Something with a heavily asynchronous slant would be great.

Quote from the expresso:

The argument passed to each callback is beforeExit, which is typically used to assert that callbacks have been invoked.

You can use beforeExit to test asynchronous functions.


TIP: Follow TJ Holowaychuk on GitHub, because he creates very good open-source code.