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
[email protected] node_modules/make
[email protected] node_modules/test
└── [email protected]
Am I missing something very simple? My test suite is as follows:
'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();
});
});
{
"name": "nockmarket"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"jquery" : "1.7.3"
, "mocha": "1.3.0"
, "should": "1.0.0"
}
}
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.
NPM is the node package manager. If you're running
npm install
you're just installing the modules make
and test
, which is not what you want. If you want to run your tests, what you need to do is to run you make file
make -f your_make_file
, which is configured to run your mocha
tests.
If your make file has a standard name (like makefile
or Makefile
, for example), you don't even need to specify it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments