I encountered an issue:
Error: Type Error - Cannot read property '$scope' of undefined
at $controller (angular/angular.js:10327:28)
at angular-mocks/angular-mocks.js:2221:12
at Context. (src/client/app/peer-review/post-visit.controller.spec.js:11:18)
This error occurs when conducting tests on an angularJS controller using mocha and karma.
The test initialization that triggers this error is as follows:
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;
});
});
Note: The controller being tested does not require $scope, and tests on other controllers within the same module are passing without any issues.