Skip to content

Unit Testing & Code Coverage With Geddy

elayman edited this page Apr 26, 2013 · 2 revisions

Background:

node-unit starts a new process when it executes tests and thus the Geddy environment is not initialized. After mucking around with it for a while, it seemed most appropriate to search for another solution, at which point, I turned to Mocha: http://visionmedia.github.com/mocha/

It's has many supported test syntaxes so it should fit almost anyone's needs and I believe it supports jscoverage (which I will look into soon).

To set up:

Modify your jakefile for running Mocha like this one: https://gist.github.com/BryanDonovan/5022389

Read Mocha's documentation for setting up tests and you're good to go

Run: geddy jake test-run (or whatever you named your jake task)

Link to original issue page: https://github.com/mde/geddy/issues/337 Many thanks to @MiguelMadero for his quick help.

EDIT: Here is a link to my Jakefile and one Mocha test file. This code creates a new directory next to the app directory and code covers the code there using node-jscoverage, then runs tests. (read the README first if you need help) https://github.com/elayman/GeddyUnitTest