Unit test modal

I’m checking my coverage report and i’m getting some small percentages for not testing the following (opening and closing). I’m using jasmine so is it possible to write a test for this?

// Open the Review modal
$scope.openIt = function () {

// Close the Share modal
$scope.closeIt = function () {

Thank you!


I’m too familiar with jasmine, but if you need some help with testing you can always check out the tests that we use.



My problem was that how can you test the template of your modal. I’ve checked the unit tests of the modal, and found that if you want to test the DOM, you have an interface for this. For example, you can test the classes of your element like this:


But what about other DOM tests? How can you reach the DOM of your modal? I’ve found that you can get the template through yourModalInstance.modalEl. But can I get the parsed template of the modal straight, without compiling it?

Fortunately you have a helper method, yourModalInstance.$el, which you can get the parsed dom through like this:


So the answer is yourModalInstance.$el, if you’d like to use jquery to test, and yourModalInstance.modalEl, if you want to test the raw template.