Skip to content

Instantly share code, notes, and snippets.

@gregberge
Last active February 20, 2018 06:54
Show Gist options
  • Save gregberge/42c56d0cd33baabf59ff to your computer and use it in GitHub Desktop.
Save gregberge/42c56d0cd33baabf59ff to your computer and use it in GitHub Desktop.
Angular controller test using mocha.
describe('My controller', function () {
var scope, createController;
beforeEach(module('app.controllers'));
beforeEach(inject(function ($injector) {
var $rootScope = $injector.get('$rootScope');
var $controller = $injector.get('$controller');
scope = $rootScope.$new();
createController = function () {
return $controller('CustomCtrl', {$scope: scope});
};
}));
afterEach(function () {
scope.$destroy();
});
});
@roshanpati
Copy link

Where did you define "inject" and "module"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment