I am getting the error:
TypeError: Cannot read property '$scope' of undefined
at $controller (bower_components/angular/angular.js:10327:28)
at bower_components/angular-mocks/angular-mocks.js:2221:12
at Context. (src/client/app/peer-review/post-visit.controller.spec.js:11:18)
When running tests on an angularJS controller with mocha and karma.
The initialisation of the test it is trying to run is:
describe('PostVisitController', function () {
var controller;
beforeEach(function () {
bard.appModule('app.peer-review');
bard.inject('$controller', '$log');
controller = $controller('PostVisitController');
});
bard.verifyNoOutstandingHttpRequests();
it('should be created successfully', function () {
expect(controller).to.be.defined;
});
});
The controller it is testing doesn't require $scope, and tests on other controllers in the same module are passing fine.