samedi 28 mars 2015

Unknown provider : error when trying to use module.config and jasmine tests

I have an Asp.Net MVC App where i set the following in my cshtml file.



<script type="text/javascript">
(function (app) {
app.constant('appPath', '@appPath');
})(angular.module('myApp'));
</script>


Then i have the following jasmine spec .



describe("mytest", () => {
beforeEach(() => {
module("myApp",($provide: ng.auto.IProvideService) => {
$provide.value("appPath", "http://testpath");
});
});
it('does its thing', function () {
// some test
});});


But it throws the following error,failed to instantiate module myApp due to error:[$injector:unpr] unknown provider 'appPath'. Is this because app.constant, that is inside the cshtml file does not get set, when i am running in test mode ?


Aucun commentaire:

Enregistrer un commentaire