Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wait helper. #112

Merged
merged 2 commits into from
Oct 20, 2015
Merged

Add wait helper. #112

merged 2 commits into from
Oct 20, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Oct 19, 2015

This allows component integration tests that need to deal with async interactions to have an easy way to model their tests.

Example test (assuming the component does some async in an action triggered by the button click):

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('{{my-foo}}');

  this.$('button').click();

  return wait()
    .then(() => {
      // assertions for after async behavior
    });
});

The guts of this wait helper are pulled from the wait acceptance test helper in Ember itself. Eventually we may be able to make Ember itself provide an implementation that we can share here and in the acceptance testing world.

@ef4
Copy link
Contributor

ef4 commented Oct 19, 2015

👏

I think the stock integration test wait also waits for any pending ajax, using ajaxstart events on window. That is something we can add here.

This allows component integration tests that need to deal with async
interactions to have an easy way to model their tests.

Example test (assuming the component does some async in an action
triggered by the button click):

```javascript
import { moduleForComponent, test } from 'ember-test-helpers';
import waitForPendingRunLoops from 'ember-test-helpers/wait';

test('it works when async exists in an event/action', function(assert) {
  this.render('{{my-foo}}');

  this.$('button').click();

  return waitForPendingRunLoops()
    .then(() => {
      // assertions for after async behavior
    });
});
```

The guts of this `wait` helper are pulled from the `wait` acceptance
test helper in Ember itself. Eventually we may be able to make Ember
itself provide an implementation that we can share here and in the
acceptance testing world.
@rwjblue
Copy link
Member Author

rwjblue commented Oct 19, 2015

Added AJAX waiting support.

rwjblue added a commit that referenced this pull request Oct 20, 2015
@rwjblue rwjblue merged commit 82ca038 into emberjs:master Oct 20, 2015
@rwjblue rwjblue deleted the add-wait-helper branch October 20, 2015 13:37
@knownasilya
Copy link
Contributor

Looks like an advanced testing tutorial/video might be nice, since there have been so many testing changes recently.

@adong
Copy link

adong commented May 21, 2020

I just want to point out that wait helper has been removed in #818. 😢

Copy link
Member Author

rwjblue commented May 21, 2020

Long live settled! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants