Skip to content

Instantly share code, notes, and snippets.

@moqada
Created June 26, 2014 04:46
Show Gist options
  • Save moqada/f7fe29ac8031bad58945 to your computer and use it in GitHub Desktop.
Save moqada/f7fe29ac8031bad58945 to your computer and use it in GitHub Desktop.
CoffeeScript で AngularJS のテストを書くときに気をつけること ref: http://qiita.com/moqada/items/ebc052415020f178ee76
Error: [ng:areq] Argument 'fn' is not a function, got $HttpProvider
http://errors.angularjs.org/1.3.0-beta.7/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20%24HttpProvider
'use strict'
describe 'Service: sampleHttpInterceptor', ->
$httpProvider = null
beforeEach module 'sample.http'
beforeEach module (_$httpProvider_) ->
_$httpProvider_.interceptors.push 'sampleHttpInterceptor'
$httpProvider = _$httpProvider_
# ここに null とか undefined とか入れないと落ちる
null
it 'defined', inject (sampleHttpInterceptor) ->
expect(sampleHttpInterceptor).toBeDefined()
it 'intercepted', ->
expect($httpProvider.interceptors).toContain 'sampleHttpInterceptor'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment