Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown $rootElementProvider: Qunit + angularjs integration [closed]

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?

like image 433
Artem Konovalenkov Avatar asked Apr 29 '13 07:04

Artem Konovalenkov


1 Answers

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/

like image 143
TrevDev Avatar answered Nov 03 '22 02:11

TrevDev