samedi 31 octobre 2015

Jasmine test for angular directive: Actual is not a function

I have the following tests:

it("should load the directive without error", function () {
    expect($compile(inputElement)($scope)).not.toThrow();
});

and my input element contains my directive. My directive has a require on ngModel and the purpose of the test is for it to compile without error if the element the directive is on has the ngModel directive. All of this works in production, but for some reason my test is failing and I get the message:

Actual is not a Function in __pathToJasmine/jasmine.js (line 2207)

I'm also using Jasmine 2.0.

Now, I realize that the actual function is $compile, and once it's called with $scope it's not longer a function, but how would I test whether my directive compiled successfully or not?

Aucun commentaire:

Enregistrer un commentaire