использовали qunit в нашей команде, и я пытаюсь выяснить, как тестировать директивы с qunit. Я следую примеру https://egghead.io/lessons/angularjs-unit-testing-a-directiveКак проверить директивы angularjs с qunit?
Вот директива:
var app = angular.module("app", []);
app.directive("ehSimple", function() {
return function(scope, element) {
element.addClass("plain");
}
})
А вот мой QUnit тест до сих пор
var injector = angular.injector(['ng', 'app']);
test('ehSimple directive', function() {
var element;
var $scope;
injector.invoke(['$compile', function($compile, $rootScope) {
$scope = $rootScope;
element = angular.element('<div eh-simple>{{ 2 + 2}}</div>');
$compile(element)($rootScope);
}]);
$scope.$digest();
console.log(element.html());
ok(element.html() == '4');
});
Когда я пытаюсь запустить тест с Карой я получаю:
Died on test #1 @/home/.../tests/qunit/test_directives.js:34
: [ng:areq] Argument 'scope' is required
Очень расстраивает любые идеи?