Skip to content

Commit

Permalink
add waitFor msg
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer committed Apr 5, 2018
1 parent dc1ec8e commit de208ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions addon-test-support/@ember/test-helpers/dom/wait-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { nextTickPromise } from '../-utils';
@param {number} [options.count=null] the number of elements that should match the provided selector (null means one or more)
@returns {Element|Array<Element>} the element (or array of elements) that were being waited upon
*/
export default function waitFor(selector, { timeout = 1000, count = null } = {}) {
export default function waitFor(selector, { timeout = 1000, count = null, timeoutMessage = 'waitFor timed out' } = {}) {
return nextTickPromise().then(() => {
if (!selector) {
throw new Error('Must pass a selector to `waitFor`.');
Expand All @@ -32,6 +32,6 @@ export default function waitFor(selector, { timeout = 1000, count = null } = {})
} else {
callback = () => getElement(selector);
}
return waitUntil(callback, { timeout });
return waitUntil(callback, { timeout, timeoutMessage });
});
}
4 changes: 2 additions & 2 deletions tests/unit/dom/wait-for-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ module('DOM Helper: waitFor', function(hooks) {

let start = Date.now();
try {
await waitFor('.something', { timeout: 100 });
await waitFor('.something', { timeout: 100, timeoutMessage: '.something timed out' });
} catch (error) {
let end = Date.now();
assert.ok(end - start >= 100, 'timed out after correct time');
assert.equal(error.message, 'waitUntil timed out');
assert.equal(error.message, '.something timed out');
}
});
});

0 comments on commit de208ec

Please sign in to comment.