-
Notifications
You must be signed in to change notification settings - Fork 470
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
BREAKING: make waitForDomChange accept a callback #376
Comments
Oh, and I welcome your thoughts :) |
TBH I thought that |
Interesting idea. I wonder what the ramifications of that would be. I'd love to hear from others, but I'm liking this idea a lot. We could remove |
I rarely use |
I've used some Let's say clicking an element results in changes to the dom fireEvent.click(element);
await waitForDomChange(container); // <--- this doesn't work, the change had already happened const changePromise = waitForDomChange(container);
fireEvent.click(element);
await changePromise; // <--- this works, we started listening for changes before firing the event Same problem with I like the approach of having a callback in
|
@le0nik |
Even though I'm not a heavy user of |
Closes #376 BREAKING CHANGE: `waitForElement` is deprecated in favor of `find*` queries or `wait`. BREAKING CHANGE: `waitForDomChange` is deprecated in favor of `wait` BREAKING CHANGE: default timeout for async utilities is now 1000ms rather than 4500ms. This can be configured: https://testing-library.com/docs/dom-testing-library/api-configuration
🎉 This issue has been resolved in version 7.0.0-beta.2 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Closes #376 Closes #416 BREAKING CHANGE: `waitForElement` is deprecated in favor of `find*` queries or `wait`. BREAKING CHANGE: `waitForDomChange` is deprecated in favor of `wait` BREAKING CHANGE: default timeout for async utilities is now 1000ms rather than 4500ms. This can be configured: https://testing-library.com/docs/dom-testing-library/api-configuration
Closes #376 Closes #416 BREAKING CHANGE: `waitForElement` is deprecated in favor of `find*` queries or `wait`. BREAKING CHANGE: `waitForDomChange` is deprecated in favor of `wait` BREAKING CHANGE: default timeout for async utilities is now 1000ms rather than 4500ms. This can be configured: https://testing-library.com/docs/dom-testing-library/api-configuration
Closes #376 Closes #416 BREAKING CHANGE: wait is now deprecated in favor of waitFor (which has basically the same API except it requires a callback and it also accepts optional mutation observer arguments). BREAKING CHANGE: `waitForElement` is deprecated in favor of `find*` queries or `wait`. BREAKING CHANGE: `waitForDomChange` is deprecated in favor of `wait` BREAKING CHANGE: default timeout for async utilities is now 1000ms rather than 4500ms. This can be configured: https://testing-library.com/docs/dom-testing-library/api-configuration
🎉 This issue has been resolved in version 7.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Just an idea. When I use
wait
, I give it an assertion to wait for something to pass and I know my callback is called every 50ms until it passes. The nice thing about this is that we don't care what goes on during that time. We just wait for that assertion to pass.However with
waitForDomChange
, we're just waiting for a single update to the DOM, but that's less helpful and arguably a bit more like implementation details because we shouldn't care how many DOM changes there are, we should wait until the DOM changes to a desirable state.I'd like to think of
waitForDomChange
as a variant towait
which re-runs a callback whenever the DOM changes rather than arbitrarily every 50ms.So it'd look like this (the same as
waitForElement
):I expect that it would work similar to
wait
if you provide no callback. So this would be a breaking change only for people who are passingoptions
(they would have to pass a callback ofundefined
ahead of the options, or even better, an actual callback making an actual useful assertion).So this change would not break existing code that does this:
But it would break existing code that does this:
And that would need to change to:
For the exact same behavior as before, or, preferably someone would give a callback with an assertion:
I think this is a good time to make this change considering we're about to release another breaking change: #373
The text was updated successfully, but these errors were encountered: