Reputation: 2292
I use mocha
to test my nodejs code, and the test runs just ok, but when I use mocha test.js
to run test, it seems that the string I passed to describe
does not show.
The code is as follows:
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();
});
});
});
});
The result of mocha
command shows:
undefined ․․
✔ 2 tests complete (68 ms)
Why it shows undefined
since I already pass a string?
Upvotes: 1
Views: 1185