Performance Zone is brought to you in partnership with:

I have been a programmer since I was a young child in the Gifted and Talent Program in Rutherford, NJ back in 1979. I started programming on Commodore PETs – 4 bit. And then Apple IIs, Commodore 64s and some others. Basic, then Pascal, Fortran, C, C++, Java, JavaScript and more. I am a Senior Field Engineer with Pivotal. Tim is a DZone MVB and is not an employee of DZone and has posted 59 posts at DZone. You can read more from them at their website. View Full User Profile

Test Driven Node.js Development

09.02.2012
| 8716 views |
  • submit to reddit

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] Virile Testing for Node.JS Apps is pretty interesting and so is Headless Full Stack Testing with Zombie.js. 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.
Published at DZone with permission of Tim Spann, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)