Using the `wait` helper in Ember integration tests
Component integration tests are a powerful way to test your Ember components in relative isolation. They look something like this:
test('it renders', function(assert) {
assert.expect(2);
this.render(hbs`{{x-foo}}`);
assert.equal(this.$().text().trim(), '');
});
Sometimes, however, you'll want to handle a bit of asynchrony. Thanks to rwjblue that is now not too big of a deal with the wait
helper:
import { moduleForComponent, test } from 'ember-test-helpers';
import wait from 'ember-test-helpers/wait';
test('it works when async exists in an event/action', function(assert) {
this.render(hbs`{{my-foo}}`);
this.$('button').click();
return wait()
.then(() => {
// assertions for after async behavior
});
});
And that's about it! You'll need to update ember-qunit
to at least: v0.4.15
Cheers!
Tweet