It looks like you are missing a closing quote...
(->
describe 'Login Controller', ->
beforeEach module 'myApp' // <------ here you forgot it
it 'should initialize the controller', ->
# createController()
# $scope.init()
)()
문제
My karma.conf.coffee
is:
module.exports = (config) ->
config.set
basePath: '../../'
preprocessors:
'**/*.coffee': ['coffee']
files: [
'dist/assets/vendor.js'
'public/bower_components/angular-mocks/angular-mocks.js'
'dist/assets/app.js'
'test/public/**/*.coffee'
]
singleRun: true
frameworks: ['mocha']
browsers: ['PhantomJS']
reporters: ['story']
logLevel: config.LOG_INFO
coffeePreprocessor:
options:
bare: true
sourceMap: false
transformPath: (path) ->
path.replace(/\.coffee$/, '.js')
vendor.js
is a concatenated js of angular.js
, angular-route.js
and angular-strap.js
. app.js
is all of my angular code concatenated.
I have a test: test/public/controllers/login.spec.coffee
that looks like:
(->
describe 'Login Controller', ->
beforeEach module 'myApp
it 'should initialize the controller', ->
# createController()
# $scope.init()
)()
When I run the test, I get:
PhantomJS 1.9.7 (Mac OS X) - Login Controller:
PhantomJS 1.9.7 (Mac OS X) "before each" hook: [object Object] FAILED
PhantomJS 1.9.7 (Mac OS X): Executed 1 of 1 (1 FAILED) ERROR (0.005 secs / 0 secs)
PhantomJS 1.9.7 (Mac OS X)
PhantomJS 1.9.7 (Mac OS X) Login Controller "before each" hook: [object Object] FAILED
TypeError: 'undefined' is not an object (evaluating 'fn.call')
What am I doing wrong?
해결책
It looks like you are missing a closing quote...
(->
describe 'Login Controller', ->
beforeEach module 'myApp' // <------ here you forgot it
it 'should initialize the controller', ->
# createController()
# $scope.init()
)()
다른 팁
(->
describe 'Login Controller', ->
beforeEach module 'myApp
it 'should initialize the controller', ->
# createController()
# $scope.init()
)()
You are missing a ' after myApp
beforeEach module 'myApp'
always preview your coffeescript