Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

How to catch errors in component/rendering test?

$
0
0

@Garrick wrote:

Version: ember@~3.1.0, ember-cli@~3.1.4

My component has a computed property that throws an error when the component is used without passing an attribute to replace the computed property.

How do I catch the error in my rendering test? Both assert.throws and assert.rejectsdo not catch the error.

My computed property looks like:

someProperty: computed(function() {
    throw new Error('some error');
})

My test looks like:

module('my-component test', function(hooks) {
    setupRenderingTest(hooks);

    test('throws', function(assert) {
        // Doesn't work, because render returns a promise.
        assert.throws(() => {
            render(hbs`{{my-component}}`);
        });

        // Doesn't work...
        assert.rejects(render(hbs`{{my-component}}`));
    ;})
});

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles