Unknown $ rootElementProvider: Qunit + angularjs integration

When I try to enter $ location service in unit test (qunit), I get the error: Unknown $ rootElementProvider <- $ rootElement <- $ location

Other things, regardless of location service, are entered correctly.

var $injector = angular.injector(['ng', 'myApp']); var $location = $injector.get('$location'); 

source: http://jsfiddle.net/H4qGb/5/

Another strange error occurs in the second test.

Does anyone know how to integrate angular with the best qunit way?

+6
source share
1 answer

You should use angularjs frames.

http://code.angularjs.org/1.1.5/angular-mocks.js

Then you can instruct your injector to also use these bullying.
var $injector = angular.injector(['ngMock','ng', 'myApp']);

http://jsfiddle.net/jxVDT/

+8
source

Source: https://habr.com/ru/post/943864/


All Articles