
Unit Testing Best Practices in AngularJS | via codeship - uurr
http://blog.codeship.io/2013/10/31/unit-testing-best-practices-in-angularjs.html
======
tatalegma
Pretty good, thanks for sharing. I'm learning angular and this was really
useful to me.

One comment I have is I don't agree with some of the advice about integration
testing. Integration testing shouldn't mock anything (except maybe truly
external 3rd party stuff like analytics). If your app is interacting with your
own internal services, for example to do user authentication, you should
interact with a real instance of that service, not a mocked one. This way you
don't run into the situation where the interaction between the angular code
and the authentication service is broken, but your tests think everything is
fine.

I used to unit test extensively, and I still do, but I now prefer integration
tests as my primary form of testing. It's more important to me to know that
major features that span across modules/service layers are working. Most of
the time the low level testing isn't as necessary if I know that things are
working at the higher level.

I think mocking in integration tests is a cop out. First, it's by definition
not an integration test (but I hate those conversations or blog posts where
people haggle over the definitions of "unit test", "acceptance test",
"integration test", "smoke test", etc). Second, you should take the time to
set up an actual environment that mirrors production as closely as possible,
and run integration tests in that environment. This means running integration
tests against services deployed to real servers that hit real databases.

------
shidhincr
Wow ! Really a good one. One problem I faced was missing a good test reporter
for AngularJS unit tests.

