I am following the book Jump Start Node.js and am starting to write tests with mocha. My test output should show something similar to:
3 of 3 tests failed:
1) exchange buy should add a BUY nockmarket order:
ReferenceError: exhange is not defined
But instead what I am seeing is:
npm install make test
npm http GET https://registry.npmjs.org/make
npm http GET https://registry.npmjs.org/test
npm http 200 https://registry.npmjs.org/make
npm http 200 https://registry.npmjs.org/test
npm http GET https://registry.npmjs.org/ansi-font/0.0.2
npm http 200 https://registry.npmjs.org/ansi-font/0.0.2
npm http GET https://registry.npmjs.org/ansi-font/-/ansi-font-0.0.2.tgz
npm http 200 https://registry.npmjs.org/ansi-font/-/ansi-font-0.0.2.tgz
make@0.0.0 node_modules/make
test@0.6.0 node_modules/test
└── ansi-font@0.0.2
Am I missing something very simple? My test suite is as follows:
exchange.test.js
'use strict';
var assert = require('assert')
, should = require('should');
var exchangeData = {};
suite('exchange', function() {
test('buy should add a BUY nockmarket order', function(done) {
exhangeData = exchange.buy(40, 100, exchangeData);
exchangeData.buys.volumes[40].should.eql(100);
done();
});
test('sell should add a SELL nockmarket order', function(done) {
exchangeData = exchange.sell(41, 200, exchangeData);
exchangeData.sells.volumes['41'].should.eql(200);
done();
});
test('sell should produce trades', function(done) {
exchangeData = exchange.sell(40, 75, exchangeData);
exchangeData.trades[0].price.should.eql(40);
exchangeData.trades[0].volume.should.eql(75);
exchangeData.buys.volumes[40].should.eql(25);
exchangeData.sells.volumes[41].should.eql(200);
done();
});
});
package.json
{
"name": "nockmarket"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"jquery" : "1.7.3"
, "mocha": "1.3.0"
, "should": "1.0.0"
}
}
Makefile
test:
@./node_modules/.bin/mocha -u tdd
.PHONY: test
According to the books instructions I have Node installed correctly and I can run simple examples with no issues.
Any ideas would be very helpful.
Thanks,
T.