Skip to content

Instantly share code, notes, and snippets.

@alexeygolev
Created August 14, 2012 02:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexeygolev/3345781 to your computer and use it in GitHub Desktop.
Save alexeygolev/3345781 to your computer and use it in GitHub Desktop.
angular.js jasmine test spec for controller defined inside a module in coffeescript
'use strict'
#jasmine specs for controllers go here
describe 'PhoneCat controllers', ->
describe 'PhoneListCtrl', ->
beforeEach module 'phonesCat.controllers'
ctrl = undefined
scope = undefined
beforeEach inject ($controller, $rootScope) ->
scope = $rootScope.$new();
ctrl = $controller 'PhoneListCtrl', {
$scope: scope
}
it 'should create "phones" model with 3 phones', ->
expect(scope.phones.length).toBe 3
Copy link

ghost commented Oct 8, 2013

Where are the module and inject functions defined? I'm getting an error when running the test with karma...

@hunanboy
Copy link

For inject function, see this https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
It says that "This function is also published on window for easy access."

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