AngularJS Developer Question:
Download Questions PDF

Explain which means of communication between modules of your application are easily testable?

Answer:

Using a service is definitely easy to test. Services are injected, and in a test either a real service can be used or it can be mocked.

Events can be tested. In unit testing controllers, they usually are instantiated. For testing events on $rootScope, it must be injected into the test.

Testing $rootScope against the existence of some arbitrary models is testable, but sharing data through $rootScope is not considered a good practice.

For testing direct communication between controllers, the expected results should probably be mocked. Otherwise, controllers would need to be manually instantiated to have the right context.

Download AngularJS Developer Interview Questions And Answers PDF

Previous QuestionNext Question
List down a few ways to improve performance in an AngularJS app?Tell me what is service method?