0
我正在跟蹤本書Jump Start Node.js,並開始使用mocha編寫測試。我的測試結果應顯示類似於:使用摩卡測試節點時未顯示測試結果
3 of 3 tests failed:
1) exchange buy should add a BUY nockmarket order:
ReferenceError: exhange is not defined
但不是我所看到的是:
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]
我缺少的東西很簡單呢?我的測試套件如下:
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
據我已經安裝節點的圖書的說明正確,我可以運行沒有問題的簡單示例。
任何想法都會非常有幫助。
謝謝, T.
你在跑什麼來得到這個錯誤?一個make腳本?或者你只是在運行'npm install make test'?因爲如果這是你正在運行的,那是預期的輸出。 –
我正在運行npm install make test –