I’m new to karma & jasmine, but I’ve successfully completed a few tutorials. However, I’m having trouble with my specific ionic setup and I know it has to do with my app ‘starter’ and my ‘starter.controllers’:
// app.js
// Ionic Starter App
// ...
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'starter.controllers'])
.run(function($ionicPlatform, $http, $rootScope) {
//...
// controllers.js
angular.module('starter.controllers')
// ...
.controller('AppCtrl', function ($scope) {
$scope.hello = 'HELLO';
// ...
// AppCtrl-spec.js (test)
describe('Unit: AppCtrl', function() {
// Load the module with ContainerContactCtrl, add your module name in here!
beforeEach(module('starter'));
// beforeEach(module('starter.controllers')); // also tried this
var ctrl, scope;
// inject the $controller and $rootScope services
// in the beforeEach block
beforeEach(inject(function($controller, $rootScope) {
// create a new scope that's a child of the $rootScope
scope = $rootScope.$new();
// create the controller
ctrl = $controller('AppCtrl', {
$scope: scope
});
}));
it('should do this and that',
function() {
expect(scope.hello).toEqual("HELLO"); // LINE 37: test run gives error that scope is undefined
});
});
BUT, I keep getting an error that “scope” is undefined on the line (37) above.
What am I missing?
Thank you,
~Todd