-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing #4
Comments
Both! Ideally, you want unit tests for all of your controllers, directives, and services, as well as e2e tests. |
I'd also be very interested in a testing mock here.. |
I wrote a test mock myself, maybe it is interesting for you:
It allows to setup listener functions and on emit they simply all get called back with the data emitted. Testing can by done synchronously like this:
Simply load the mock module after the main module, that will overwrite the previous socket service. |
Hi Guys I have taken SouthDesign's example above.. Tweaked it a bit and incorporated it into a Karma test suite for my controller. You can check out my controller test here... https://github.com/hackify/hackify-server/blob/master/test/controllers.test.js Pull the whole thing if you like and follow the readme instructions to run the Karma tests. I found that I needed to add a Receive event to differentiate the mock emits and the emits I expect from the controller. @btford happy to do a pr for this, not super sure how to approach it tho. Michael |
@mdausmann I created a package using your mock object that can be downloaded using bower which is located here: https://github.com/nullivex/angular-socket.io-mock This is working well for me so far and I am testing with Mocha, Chai and using RequireJS. Thought you might find it useful. I load it as a drop in replacement for the angular-socket-io package and it works like a charm. |
Fantastic Bryan I will check it out
|
@nullivex nice! |
@mdausmann thanks, worked great! |
@nullivex i got undefined on "socketMock = new sockMock($rootScope);" Could you help me on this ? |
@anandi2i not sure but try
If that doesn't work, look through his repo to find where he defined the class sockMock. |
Hi,
Nice tutorials, thanks.
How would you go about writing tests for a setup like this one?
mock socket.io server connection in the unit tests in the angular client and vice versa?
angular e2e tests for client and server together?
Regards,
Remko
The text was updated successfully, but these errors were encountered: