Thursday, July 1, 2010

Getting Started with Vows.js and Fab.js

‹prev | My Chain | next›

While on vacation, I have spent much of my chain making little tweaks here and there, but the learning went on the back burner. I pick back up with that starting with vows.js, which claims to be BDD for node.js. I am none too sure how well it will work with fab.js, but I am eager to find out!

The vows.js documentation is quite detailed, possibly to a fault, but install is simple enough:
cstrom@whitefall:~/repos/my_fab_game$ npm install vows
The "ini" module will be removed in future versions of Node, please extract it into your own code.
npm configfile /home/cstrom/.npmrc
npm sudo false
npm cli [ 'install', 'vows' ]
npm install pkg vows
npm fetch data vows
npm GET vows
npm install pkg vows
npm install pkg vows@0.4.5
npm readJson /home/cstrom/.node_libraries/.npm/.cache/vows/0.4.5/package.json
npm GET vows/0.4.5
npm ok
Running the new executable, I get:
cstrom@whitefall:~/repos/my_fab_game$ vows
vows runner couldn't find test folder
vows runner exiting
OK. I need to add a test folder and in there, I create a test/just_playing.js suite:
var suite = vows.describe('just_playing');
So there is one describe per test file. It describes the suite of tests in the file (hence the name). That is a bit different from describe blocks in RSpec, of which there can be multiple in a single file.

Running vows now, however, I get:
cstrom@whitefall:~/repos/my_fab_game$ vows
var suite = vows
ReferenceError: vows is not defined
at Object.<anonymous> (/home/cstrom/repos/my_fab_game/test/just_playing.js:1:63)
at Module._compile (module:384:23)
at Module._loadScriptSync (module:393:16)
at Module.loadSync (module:296:10)
at loadModule (module:241:16)
at require (module:364:12)
at /home/cstrom/bin/vows:326:19
at Array.reduce (native)
at importSuites (/home/cstrom/bin/vows:325:18)
at Object.<anonymous> (/home/cstrom/bin/vows:168:15)
Gah! I am terrible about skipping ahead too quickly in the documentation. I need to require the vows module (and the assert module while I am at it):
var vows = require('vows'),
assert = require('assert');

var suite = vows.describe('just_playing');
Now when I run vows, I get:
cstrom@whitefall:~/repos/my_fab_game$ vows

undefined » (0.000s)
Ah, Progress.

That is about as far as I am going to make it tonight. Up tomorrow, converting my existing fab.js based tests over to vows.js. I have the feeling that full stack testing of my chained fab.js apps will prove too difficult to test, but that's what mechanized Cucumber is for. Hopefully vows.js can put me in a better position that where I am at right now with respect to BDD...

Day #151

No comments:

Post a Comment