Jasmine specs can't find ionicModal, works in browser


#1

I get this error when attempting to run jasmine tests for a controller that’s dependent upon ionicModal

Error: [$injector:unpr] Unknown provider: $ionicModalProvider <- $ionicModal
http://errors.angularjs.org/1.2.12/$injector/unpr?p0=%24ionicModalProvider%20%3C-%20%24ionicModal
    at /Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:7040:12
    at /Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10508:19
    at Object.getService [as get] (/Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10635:39)
    at /Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10513:45
    at getService (/Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10635:39)
    at Object.invoke (/Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10662:13)
    at /Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10518:71
    at Array.forEach (native)
    at forEach (/Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:7265:11)
    at Object.createInjector [as injector] (/Users/inspire/Projects/ap-app/www/js/bower_components/ionic/release/js/ionic.bundle.js:10518:3)

Chrome 33.0.1750 (Mac OS X 10.9.2): Executed 2 of 2 (2 FAILED) ERROR (0.322 secs / 0.042 secs)

controller.coffee:
angular.module(“ap.controllers”, [‘angularMoment’])
.controller(“home”, ($scope, $stateParams, Item, $ionicModal, $http) ->

I tried checking the sample apps, but can’t find any with actual tests written!

Thanks for any help! Using Ionic 0.9.25 currently.
Kevin


#2

Hi,

I had the same problem.

I solved it according to http://stackoverflow.com/a/18354910/2343743.

The solution was to add ionic as a dependency to my module.

angular.module(“ap.controllers”, [‘ionic’,‘angularMoment’])

The fact that it worked in the browser was because another module loaded ionic


#3

Thank you, davidgang! Gawd, I looked all over for this simple answer before I got here.