Skip to content

Add waitFor#369

Merged
calebeby merged 5 commits intomainfrom
wait-for
Jan 14, 2022
Merged

Add waitFor#369
calebeby merged 5 commits intomainfrom
wait-for

Conversation

@calebeby
Copy link
Copy Markdown
Member

@calebeby calebeby commented Jan 11, 2022

This is something in dom testing library that I had skipped but it seems like there are a fair number of use cases where it is useful

https://testing-library.com/docs/dom-testing-library/api-async/#waitfor

Copy link
Copy Markdown
Contributor

@Paul-Hebert Paul-Hebert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Left a few comments/questions inline.

Comment thread tests/wait-for.test.ts Outdated
Comment thread tests/wait-for.test.ts
const error3 = await waitFor(() => new Promise<never>(() => {}), {
timeout: 10,
onTimeout: (err) => {
err.message += '\nCaleb wuz here';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

* The maximum amount of time (milliseconds) that will pass between each run of the callback.
* If the MutationObserver notices a DOM change before this interval triggers,
* the callback will run again immediately.
* Default: 50ms
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we actually setting these defaults somewhere or are these just the defaults from testing library?

If they're from testing library are we worried at all that are docs could be wrong if they change those defaults? Maybe we should set these defaults to make sure the docs and implementation stay in sync?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the defaults from testing library.
Whenever there are DTL updates, I check through their changes to see if there is anything on our end we need to update. I agree that I don't want our docs to diverge from the functionality, but I also don't want our functionality to diverge from DTL's functionality. Whether we set the defaults in code here or not, we'd still have to keep an eye out to prevent it from diverging

Co-authored-by: Paul Hebert <paul@cloudfour.com>
@calebeby calebeby merged commit c0a8a0a into main Jan 14, 2022
@calebeby calebeby deleted the wait-for branch January 14, 2022 02:31
@github-actions github-actions Bot mentioned this pull request Jan 14, 2022
@calebeby calebeby mentioned this pull request Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants