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

Include selector in waitFor()'s default timeout message #392

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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