我mocha
用来测试我的nodejs代码,测试运行正常,但是当我mocha test.js
用来运行测试时,我传递给的字符串describe
似乎没有显示。
代码如下:
var assert = require("should");
describe("FrontEndTest", function(){
describe('websocket establish connection', function(){
it('should establish connection correctly', function(done){
var res;
var wsClient = create_ws_client('ws://127.0.0.1:9876','brain_burst');
wsClient.on('connect', function(connection){
res = true;
res.should.be.true;
done();
});
wsClient.on('connectFailed', function(error){
res = false;
res.should.be.true;
done();
});
console.log(res);
});
it('should disconnected by server.(also, that may crash server if there is not a protocol validation)', function(done){
var res;
var wsClient = create_ws_client('ws://127.0.0.1:9876');
wsClient.on('connect', function(connection){
res = true;
res.should.be.false;
done();
});
wsClient.on('connectFailed', function(error){
res = false;
res.should.be.false;
done();
});
});
});
});
命令结果mocha
显示:
未定义․․</p>
✔ 完成 2 次测试(68 毫秒)
为什么它显示undefined
,因为我已经传递了一个字符串?