First of all, your code isn't asynchronous, you need to use process.nextTick or setImmediate and, in the current situation the test case should look like I wrote below:
code.js
var Util = function () {
this.factorial = function (n) {
if (n == 1) {
return n;
} else {
return n * this.factorial(n - 1);
}
}
};
exports.Util = Util;
test.js
var vows = require('vows'),
assert = require('assert'),
Util = require('./code').Util;
vows.describe('Testing Utils').addBatch({
'Test Factorial async': {
topic: new Util,
'The output must be 120': function (util) {
assert.equal(util.factorial(5), 120);
}
}
}).run();