Skip to content

Commit

Permalink
Merge pull request #392 from gabrielgrant/add-selector-to-wait-for-de…
Browse files Browse the repository at this point in the history
…fault-timeout-message

Include selector in waitFor()'s default timeout message
  • Loading branch information
rwjblue authored Jul 9, 2018
2 parents 47b094d + c13946a commit e172fe6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions addon-test-support/@ember/test-helpers/dom/wait-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import { nextTickPromise } from '../-utils';
@param {number} [options.count=null] the number of elements that should match the provided selector (null means one or more)
@return {Promise<Element|Element[]>} resolves when the element(s) appear on the page
*/
export default function waitFor(
selector,
{ timeout = 1000, count = null, timeoutMessage = 'waitFor timed out' } = {}
) {
export default function waitFor(selector, { timeout = 1000, count = null, timeoutMessage } = {}) {
return nextTickPromise().then(() => {
if (!selector) {
throw new Error('Must pass a selector to `waitFor`.');
}
if (!timeoutMessage) {
timeoutMessage = `waitFor timed out waiting for selector "${selector}"`;
}

let callback;
if (count !== null) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/dom/wait-for-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module('DOM Helper: waitFor', function(hooks) {
} catch (error) {
let end = Date.now();
assert.ok(end - start >= 100, 'timed out after correct time');
assert.equal(error.message, 'waitFor timed out');
assert.equal(error.message, 'waitFor timed out waiting for selector ".something"');
}
});

Expand Down

0 comments on commit e172fe6

Please sign in to comment.