2017-05-05 68 views
0

隨着耙茉莉花我所有的測試通過瀏覽器。爲什麼耙茉莉花通過,但耙茉莉花:ci失敗TypeError:undefined不是函數?

隨着耙茉莉,2種規格失敗:

TypeError: undefined is not a function (evaluating 'expect(player).not.toBePlaying(song)') in http://localhost:36091/__spec__/PlayerSpec.js (line 28) 

我已經配置了我的spec/javascripts/support/jasmine.yml文件,以便它具有

src_files: 
    - src/Player.js 
    - src/Song.js 
spec_files: 
    - '**/*[sS]pec.js' 
src_dir: 
spec_dir: spec 

src/Song.js有:

function Song() { 
... 

爲什麼rake jasmine:ci失敗的這兩個例子?

的第一個失敗的代碼是:

it("should be able to play a Song", function() { 
    player.play(song); 
    expect(player.currentlyPlayingSong).toEqual(song); 

    //demonstrates use of custom matcher 
    expect(player).toBePlaying(song); # <-- error here 
}); 

Song.js似乎被加載,因爲如果我刪除所有5例失敗。

回答

0

我需要自定義匹配器toBePlaying

我能得到所有的規格路過的spec/javascripts/support/jasmine.yml文件更改此:

src_files: 
    - src/Player.js 
    - src/Song.js 
    - spec/SpecHelper.js # <--- Added to include the custom helper 'toBePlaying' 

我曾試圖將它添加到spec_files部分,但它需要列入src_files