TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Unit Testing Best Practices in AngularJS

71 pointsby andyshoraover 11 years ago

5 comments

andrewdaveyover 11 years ago
If you need end-to-end, browser-based, testing as well, check out Protractor: <a href="https://github.com/angular/protractor/blob/master/README.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;angular&#x2F;protractor&#x2F;blob&#x2F;master&#x2F;README.md</a><p>It&#x27;s built on top of WebDriverJS. I&#x27;ve been playing with it today and so far it&#x27;s working very well.
nickprestaover 11 years ago
Just to add, <a href="http://www.yearofmoo.com/2013/09/advanced-testing-and-debugging-in-angularjs.html" rel="nofollow">http:&#x2F;&#x2F;www.yearofmoo.com&#x2F;2013&#x2F;09&#x2F;advanced-testing-and-debugg...</a><p>A great article in a series of AngularJS articles, written by Matias Niemelä.
mvzinkover 11 years ago
Great article. One thing I wish got more coverage is testing directives: it&#x27;s already much easier than most DOM-testing methods (though it can&#x27;t replace selenium etc.), but doing it well and consistently has proven difficult and I don&#x27;t test most of my directives. For example, I had to modify the triggerHandler function in Angular to allow sending fake key presses since it didn&#x27;t have a built in way (at least a few months ago) to specify the &quot;which&quot; property on the event.<p>Also, If you&#x27;re in Chicago, the Angular meetup group will be talking about testing on November 20th: <a href="http://www.meetup.com/AngularJS-Chicago/" rel="nofollow">http:&#x2F;&#x2F;www.meetup.com&#x2F;AngularJS-Chicago&#x2F;</a>
评论 #6562179 未加载
tegeekover 11 years ago
Client side testable code is one of the pinnacle of AngularJS.<p>Reuseable declarative UI&#x27;s through Directives, reuseable business logic throug Services and view models (controllers) having only knowledge of views is a really good for maintainablity of a complex javascript app. AngualrJS can beat any framework out there (Backbone, Ember, etc.) when it comes to having testable &amp; manageable code.<p>If your product is going to be complex, AngularJS is a no-brainer deal.
评论 #6560759 未加载
评论 #6560372 未加载
ldn_tech_exec1over 11 years ago
This is great work, thanks for sharing!