-
Notifications
You must be signed in to change notification settings - Fork 471
feat(wait): wait will now also run your callback on DOM changes #415
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
Changes from all commits
6105400
5e08893
6e793e0
e7f7d11
4a68f39
393ba2f
a00cc96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,5 +61,3 @@ test('exposes debug method', () => { | |
`) | ||
console.log.mockClear() | ||
}) | ||
|
||
/* eslint no-console:0 */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,5 +176,3 @@ export { | |
prettyRoles, | ||
isInaccessible, | ||
} | ||
|
||
/* eslint no-console:0 */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,11 @@ import { | |
} from './helpers' | ||
import {getConfig} from './config' | ||
|
||
let hasWarned = false | ||
|
||
// deprecated... TODO: remove this method. People should use wait instead | ||
// the reasoning is that waiting for just any DOM change is an implementation | ||
// detail. People should be waiting for a specific thing to change. | ||
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we plan to remove this method in the next major release, should be add a warning so people know they are relying on a soon-to-be-gone method? Is it too invasive? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm kinda thinking that we should add the warning in the major version bump, and then remove it in the next one. |
||
function waitForDomChange({ | ||
container = getDocument(), | ||
timeout = getConfig().asyncUtilTimeout, | ||
|
@@ -18,6 +23,12 @@ function waitForDomChange({ | |
characterData: true, | ||
}, | ||
} = {}) { | ||
if (!hasWarned) { | ||
hasWarned = true | ||
console.warn( | ||
`\`waitForDomChange\` has been deprecated. Use \`wait\` instead: https://testing-library.com/docs/dom-testing-library/api-async#wait.`, | ||
) | ||
} | ||
return new Promise((resolve, reject) => { | ||
const timer = setTimeout(onTimeout, timeout) | ||
const observer = newMutationObserver(onMutation) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized I amended the first of those two changes. So this is all that first change was.