[Unit Testing] Testing Underscores. 3
Usually, when we do testing, we inject $compile, $rootScope into the beforeEach funciton();
Actually, there is a good pratice that we write _$compile_, _$rootScope_ instead of just $compile, $rootScope;
var element; var $scope; var $rootScope; var $compile; beforeEach(module("app")) beforeEach(inject(function(_$compile_, _$rootScope_){ $rootScope = _$rootScope_; $compile = _$compile_; $scope = $rootScope; element = angular.element("<div test-dir>{{2+5}}</div>"); element = $compile(element)($rootScope); }))
_ _ doesn't really mean anything here, it does nothing. but when you assign this to a new virable $rootScope or $compile, it can be used through all the test file.
So use this and enjoy the convenient. :)