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');
});
Source code of component.js is like:
export default Ember.Component.extend({
layout,
init() {
this._super(...arguments);
throw 'my-custom-input component error';
}
}
While my ember-cli version was 2.3.0, the test was passing. However, after I've updated my ember-cli version to 2.11.1, the test did not pass. The error was:
actual: >
false
expected: >
true
Why does ember render start to swallow the thrown exception?
Well I am not quite sure why Ember community decided to break the test explained; but here is the fix if anyone needs it.
You need to install ember-qunit-assert-helpers via
ember install ember-qunit-assert-helpers
You need to change your code that throws
an exception 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 issue at the following address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With