3.1.0 • Published 6 years ago

ember-wait-for-test-helper v3.1.0

Weekly downloads
438
License
MIT
Repository
github
Last release
6 years ago

ember-wait-for-test-helper

Deprecated

This helper is now built-in:

import { waitFor, waitUntil } from '@ember/test-helpers';

Greenkeeper badge npm version Build Status Ember Version

Wait for your application to be in a specific state before continuing the test runner.

Useful for certain jquery plugins that take time to load. You can now avoid race conditions with a hard-coded wait time.

Add this line to tests/helpers/start-app.js in your app:

import 'ember-wait-for-test-helper/wait-for';

Now you can do something like:

import { selectorToExist } from 'ember-wait-for-test-helper/wait-for';

test('it should wait before asserting', function(assert) {
  click('.button');

  waitFor(selectorToExist('.a-slow-jquery-plugin'));

  andThen(() => {
    assert.ok(find('.a-slow-jquery-plugin').length === 1);
  });
});

Custom waiters

You can define your own waiters. A waiter is a function that will continuously run until it returns true. Once the waiter returns true your test will continue running. It supports Promises.

test('it should wait before asserting', function(assert) {
  visit('/');

  waitFor(() => {
    let result = getAnswerFromSomewhere();
    return result === 42; // only continue when result is 42
  });
  // or
  waitFor(() => {
    return getAnswerFromSomewhere(result => {
      return result === 42; // only continue when result is 42
    });
  });

  andThen(() => {
    // ...
  });
});
3.1.0

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago