2015-09-16 38 views
0

我想測試我的組件。我沒有使用ember-cli.I遵循了在餘燼指南中給出的內容。但是this.subject()方法未定義。 另外,我有以下錯誤測試Ember組件時出錯

setUp failed on <test-case-name> : assert.async is not a function 
Died on test #2 : this.render is not a function 
TearDown Failed on <test-case-name> : assert.async is not a function 

我沒有使用任何異步功能。在我的測試案例中,我只寫了一行this.render()。

由於事先 KUKA

+1

2.0指南使用了ember-cli。 –

回答

0

默認情況下,在灰燼2.0,你正在寫一個集成測試,而不是一個單元測試。出於某種原因,您不允許在集成測試中訪問組件對象。

爲了使您的測試單元測試,添加unit: true到測試模塊定義:

moduleForComponent('pretty-color', { 
    unit: true, 
    // specify the other units that are required for this test 
    // needs: ['component:foo', 'helper:bar'] 
}); 

不幸的是,該文件目前已經過時,不討論組件集成測試。要了解更多關於集成測試的信息,請參見http://alisdair.mcdiarmid.org/ember-component-integration-tests/

+0

非常感謝Gaurav – KuKa