2017-03-23 15 views
2

Ember 2.12がインストールされ、コンポーネントとテストを含む新しいプロジェクトが作成され、必要な属性が提供されていない場合にエラーが発生することがあります。私はこのテストに合格することができません。Ember qunit assert.throwsが機能しません

ダミーcomponent.hbs

{{value}} 
{{yield}} 

ダミーcomponent.js

import Ember from 'ember'; 
export default Ember.Component.extend({ 
    value: Ember.computed(() => { 
    Ember.assert("Someone forgot to provide a required value attribute"); 
    }) 
}); 

ダミー部品test.js

import { moduleForComponent, test } from 'ember-qunit'; 
import hbs from 'htmlbars-inline-precompile'; 

moduleForComponent('dummy-component', 'Integration | Component | dummy component', { 
    integration: true 
}); 

test('it throws', function(assert) { 
    assert.throws(() => { 
    this.render(hbs`{{dummy-component}}`); 
    }, 'Error: Assertion Failed: Someone forgot to provide a required value attribute'); 
}); 

テストは、以下で失敗:

 
    --- 
     actual: > 
      false 
     expected: > 
      true 
     stack: > 
      [email protected]://localhost:7357/assets/test-support.js:7664:49 
      [email protected]://localhost:7357/assets/vendor.js:50288:22 
      [email protected]://localhost:7357/assets/vendor.js:28557:23 
      [email protected]://localhost:7357/assets/vendor.js:10921:14 
      [email protected]://localhost:7357/assets/vendor.js:10977:15 
      [email protected]://localhost:7357/assets/vendor.js:11101:20 
      [email protected]://localhost:7357/assets/vendor.js:11171:28 
      [email protected]://localhost:7357/assets/vendor.js:11285:19 
      [email protected]://localhost:7357/assets/vendor.js:33262:32 
      [email protected]://localhost:7357/assets/test-support.js:8538:30 
      http://localhost:7357/assets/tests.js:129:19 
      [email protected]://localhost:7357/assets/test-support.js:4609:17 
      http://localhost:7357/assets/tests.js:128:18 
      [email protected]://localhost:7357/assets/test-support.js:3696:34 
      [email protected]://localhost:7357/assets/test-support.js:3682:13 
      http://localhost:7357/assets/test-support.js:3860:15 
      [email protected]://localhost:7357/assets/test-support.js:5094:26 
      [email protected]://localhost:7357/assets/test-support.js:5077:11 
      http://localhost:7357/assets/test-support.js:4294:11 
     message: > 
      Error: Assertion Failed: Someone forgot to provide a required value attribute 
     Log: | 
      { type: 'error', text: 'null\n' } 
    ... 

全体のプロセスは、この問題を回避する溶液が既に提出github issueに設けられている

npm install -g ember-cli 
ember new ember-test 
ember g component dummy-component 
<copy.paste> template, js and the test 
ember test 
+0

もチケットを開設し、ここでいくつかの回避策を掲載しました。https://github.com/emberjs/ember-qunit/issues/256 – SergPro

+0

ほぼ同じ質問:http://stackoverflow.com/questions/42781085/ember-render -hbs-swallowing-thrown-error – ykaragol

+0

ember.jsで問題を解決しました:https://github.com/emberjs/ember.js/issues/15013 – ykaragol

答えて

2

5分未満を要しました。私は他人を助けるように問題に取り組むために適用するステップをコピーしています:

throwsエラーそのEmber.assert

ember install ember-qunit-assert-helpers 

の変更を経て、あなたのコードを燃えさし-qunitアサート-ヘルパーをインストールします。

テストクラスでは、の代わりにassert.expectAssertionを使用してください。

関連する問題