I use John papa angular style guide my controller looks like:
following the style John papa style controller style guide:
function testController() {
I would create a new module and inject it as a dependency into the app module to make it simple and testable. Testing the controller with John Papa's Style Guide:
(function () {
'use strict';
angular
.module('test')
.controller('testController', testController);
function testController() {
var vm = this;
vm.model = { name: "controllerAs vm test" };
}
})();
The spec now would look like this:
'use strict';
describe('testController', function() {
var testController;
beforeEach(module('test'));
beforeEach(function () {
inject(function($injector) {
testController = $injector.get('$controller')('testController', {});
});
});
it('should have model defined and testController.name is equal to controllerAs vm test', function() {
expect(testController).toBeDefined();
expect(testController.name).toEqual("controllerAs vm test");
});
});
Hope this helps anyone looking for similar solutions.