2017-03-23 7 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 
      runTest[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' } 
    ... 
,515,

전체 프로세스 걸린 미만 5 분

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

용액 이미 github issue 제출에 제공되는 대안; 하지만 난 다른 사람을 도울 수 있도록 문제를 해결하기 위해 적용하는 단계를 복사하고 :

throws 오류가 Ember.assert

ember install ember-qunit-assert-helpers 

변경을 통해 코드를 엠버 - qunit-어설 - 헬퍼를 설치합니다.

테스트 클래스에서 assert.throws 대신 assert.expectAssertion을 사용하십시오.