I’m working on a nodejs application. I managed to break some of the code in separate modules, that I’m testing using nodeunit, but a substantial part of my code base still relies on socket.io.
How can I test my socket.io events?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this article: Socket.IO and Asynchronous Testing with node.js.
edit: if you need to test functionality for which there is no immediate output, Jasmine BDD provides spies. These can be used to “see inside” a function and test whether certain parameters are passed etc, and are useful for mocking asynchronous calls for testing, as well as writing more functional tests:
Docs, an article and a related SO question.