Ember render hbs swallowing an abandoned error

I have a simple component integration test:

test('it throws error my-custom-input is called', function(assert) { assert.throws(() => { this.render(hbs`{{my-custom-input}}`); }, /my-custom-input component error/, 'Error must have been thrown'); }); 

The source code for the .js component is similar:

 export default Ember.Component.extend({ layout, init() { this._super(...arguments); throw 'my-custom-input component error'; } } 

While my version of ember-cli was 2.3.0, the test passed. However, after I upgraded the version of ember-cli to version 2.11.1, the test failed. Error:

  actual: > false expected: > true 

Why does ember rendering start to swallow an exception that has occurred?

+6
source share
1 answer

Well, I'm not quite sure why the Ember community decided to break the test; but here is a fix if someone needs it.

You need to install ember-qunit-assert-helpers through

 ember install ember-qunit-assert-helpers 

You need to change the throws exception code to Ember.assert , and in your test class you just need to use assert.expectAssertion instead of assert.throws .

The answer is provided from the github problem at the following address .

+4
source

Source: https://habr.com/ru/post/1015722/


All Articles