I'm working on getting Expresso set up and some tests running. I followed along with a tutorial on node tuts and have 4 tests running, and passing. Now I'm trying to get a code coverage output to show up when I run the tests, like the docs show. However, I'm sort of lost.
My super basic learning example tests are in a file called test.js in a folder called test:
var Account = require('../lib/account');
require('should');
module.exports = {
"initial balance should be 0" : function(){
var account = Account.create();
account.should.have.property('balance');
account.balance.should.be.eql(0);
},
"crediting account should increase the balance" : function(){
var account = Account.create();
account.credit(10);
account.balance.should.be.eql(10);
},
"debiting account should decrease the balance" : function(){
var account = Account.create();
account.debit(5);
account.balance.should.be.eql(-5);
},
"transferring from account a to b b should decrease from a and increase b": function(){
var accountA = Account.create();
var accountB = Account.create();
accountA.credit(100);
accountA.transfer(accountB, 25);
accountA.balance.should.be.eql(75);
accountB.balance.should.be.eql(25);
}
}
And the code itself is in lib/account.js:
var Account = function(){
this.balance = 0;
}
module.exports.create = function(){
return new Account();
}
Account.prototype.credit = function(amt){
this.balance += amt;
}
Account.prototype.debit = function(amt){
this.balance -= amt;
}
Account.prototype.transfer = function(acct, amt){
this.debit(amt);
acct.credit(amt);
}
Account.prototype.empty = function(acct){
this.debit(this.balance);
}
When I run expresso from the command line, I get:
$ expresso
100% 4 tests
Likewise, if I run expresso
with a -c
flag or a variety of other options, I get the same output. I'd like to get the code coverage output shown in the docs. I've also run the command $ node-jscoverage lib lib-cov
, and the lib-cov folder has things in it now..
What am I missing?
Best result I've found so far was to edit paths on test run:
This is run_tests.sh
#! /bin/bash
rm -Rf ./app-cov
node_modules/expresso/deps/jscoverage/node-jscoverage app/ app-cov
NODE_PATH=$NODE_PATH:/usr/local/lib/node:/usr/local/lib/node_modules:./mmf_node_modules:./app-cov node_modules/expresso/bin/expresso -c