Test Driven Node.JS Development

Posted by: bunkertor

What would a language and framework be with unit testing, BDD, and other testing methods, frameworks and systems?

So once you get beyond casual Node.JS development, you will need to start unit testing.  Node.js has a surprisingly robust and mature set of testing tools and options.  Out of the box, Node.js has Built In Assert which will let you do some basic XUnit style tests.   A step beyond that is NodeUnit, which is pretty easy to use for XUnit oriented people.  For me, it’s easy to pick up coming from doing a lot of JUnit tests.  This article is great for Using NodeUnit for Testing.  Node.js is great because so many people have developed tools, frameworks and utilities for it.  The only issue I have it some are not very mature and the options are so fragmented.  There’s no Spring framework or hibernate that garners massive usage.  So many variations and options, I wish they could work together to put together a killer Rails or Spring type group of mature, tested, interconnected tools and utilities.  Full Testing Suite – Mocha is installable via NPM and works with a CI server.  This one is pretty cool.

The source for everything testing/bdd/mocking for Node.JS is Joyent’s Testing Wiki.
There’s a number of behavior driven development tools including the polyglot tool Cucumber -> BDD Testing Tool – Cucumber.JS.  Another option is Asynchronous BDD Testing Tool – Vow.
For mocking,  Mockito Style Mock Objects – Mary Jane, looks great.   I will hope that maybe Mockito will officially support this one.
For JQuery fans, someone has ported QUnit to Node.JS [Node-Qunit]
This is just a sampling of test options.  Obviously tools like Selenium and Firebug will help you and so would JMeter and and SOAPUI.  A lot of general web testing tools are available that can do full system testing or integration testing for your Node.JS web apps.
I will be adding some examples in a future post with a github link.
Be Sociable, Share!