It works fine when I run the app. But, when I run my Jasmine test script using Karma, before it even has a chance to run any tests, I get the following error:
Error: Unexpected request: GET views/Dialog.html
When I comment out the above lines of code, the tests run fine. I understand why the error is being raised… because Jasmine knows nothing about Dialog.html. But, my question is, does Ionic/Angular provide a way to make it believe that the template URL has been loaded? This seems to be a general problem with unit testing anytime external HTML is loaded dynamically from within controller code.
I have written many tests and had to include something similar to what you suggested several times. Is there a way to avoid this? I got many templates and files so it’s not that convenient.
There is a better way to deal with templates used in tests.
This karma plugin “precompiles” templates as angular inline templates. Then karma/jasmine do not have to load the templates in the process of testing. They will be just there.