Unit Testing with Nodeunit

Let’s create a unit test for our RDF parser module. This will confirm that it does what we believe it should, and will give us an opportunity to see how to do unit testing in Node.

There are many unit-testing frameworks available through npm. A few of the most popular ones are mocha,[22] vows,[23] and nodeunit.[24] We’ll use nodeunit because it’s a relatively simple unit-testing framework, with support for asynchronous tests and deep equality checks.

Many Node modules are meant to be used as a library, but some modules, like nodeunit, are intended to run as stand-alone programs on the command line, too. To install such a module globally, use npm’s -g flag:

​ 
$ ​npm install -g nodeunit​

You can confirm ...

Get Node.js the Right Way now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.