谁能为Node提供一个坚如磐石、极其简单的单元测试呢.js使用WebSocket(Socket.io)?
我用的是插座. node 的io.js,并查看了套接字.io客户端,用于建立与测试中服务器的客户端连接.然而,我似乎错过了一些东西.
在下面的例子中,"工作……"永远不会被打印出来.
var io = require('socket.io-client')
, assert = require('assert')
, expect = require('expect.js');
describe('Suite of unit tests', function() {
describe('First (hopefully useful) test', function() {
var socket = io.connect('http://localhost:3001');
socket.on('connect', function(done) {
console.log('worked...');
done();
});
it('Doing some things with indexOf()', function() {
expect([1, 2, 3].indexOf(5)).to.be.equal(-1);
expect([1, 2, 3].indexOf(0)).to.be.equal(-1);
});
});
});
相反,我只是得到:
Suite of unit tests
First (hopefully useful) test
✓ Doing some things with indexOf()
1 test complete (26 ms)
有什么建议吗?