6/23/2015

Tweak the Angular Test By Controlling the Template

We recently finished bringing our test coverage up to 90%+ on our Angular project. The team worked hard and I am proud of our accomplishments. Going forward we are using TDD and this has proven to be an interesting experience that has provided new challenges. We have found building Angular directives through test driven development to be a little challenging since the templates haven't been built yet. We aren't going to know what to build right away, and we are loathe to break our rhythm and constantly be updating a template file. A bigger problem is the template creating an external dependency which is never a good thing for unit tests. When it comes time to do e2e testing and using Selenium or Protractor then the whole template needs to be run. If I'm starting with unit tests to define my code, how can I use a template without these problems? We found one method that we like - the $templateCache.