my test
For easy read, I delete some code.
I send a message hello
to client1
:
client1.emit('chat_to_user', {user: 'user2', message: 'hello'})
And client2 listen chat_to_user
event.
it('chat', function(done) {
client2.socket.on('chat_to_user', function(data) {
data.message.should.equal('hello')
done()
});
});
this above test is fine, test passed.
change my test, it should throw error (but not)
But when I change client2 code:
it('chat', function(done) {
client2.socket.on('chat_to_user', function(data) {
//notice here! the `data.message` should equal `hello`
data.message.should.equal('i am fine')
done()
});
});
When I run test, It should throw an error, and tell me the error reason, like follow:
AssertionError: expected 'i am fine' to be 'hello'
+ expected - actual
+"i am fine"
-"hello"
But It didn't throw error reason, It just throw an timeout error:
Error: timeout of 5000ms exceeded
So, How to throw error reason with Socket.io test?
I am using socket.io 1.0