When I try to inject $location service in unit test (qunit) I get error: Unknown $rootElementProvider <- $rootElement <- $location
Other things without $location service dependency are injected correctly.
var $injector = angular.injector(['ng', 'myApp']);
var $location = $injector.get('$location');
source: http://jsfiddle.net/H4qGb/5/
One more strange error happens in the second test.
Does anybody know how to integrate angular with qunit best way?
You should be using the angularjs mocks.
http://code.angularjs.org/1.1.5/angular-mocks.js
You can then instruct your injector to also use these mocks.var $injector = angular.injector(['ngMock','ng', 'myApp']);
http://jsfiddle.net/jxVDT/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With