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

ref(tests): Replace waitFor with waitForElementToBeRemoved in RTL #29547

Merged
merged 2 commits into from
Oct 29, 2021

Conversation

matejminar
Copy link
Member

@matejminar matejminar commented Oct 25, 2021

The waitForElementToBeRemoved async helper function uses a callback to query for the element on each DOM mutation and resolves to true when the element is removed.

Using MutationObserver is more efficient than polling the DOM at regular intervals with waitFor.

Comment on lines -17 to -20
await waitFor(() => {
expect(screen.queryByTestId('loading-indicator')).not.toBeInTheDocument();
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like some of these are not needed. If it makes our tests unstable, I'll put them back.

@matejminar matejminar marked this pull request as ready for review October 25, 2021 16:12
@matejminar matejminar requested a review from a team as a code owner October 25, 2021 16:12
@matejminar matejminar requested review from a team and removed request for a team October 25, 2021 16:12
Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

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

@matejminar Should we be summarizing the work you've been doing in https://develop.sentry.dev/frontend/#testing?

@matejminar
Copy link
Member Author

@billyvg Yeah, I'll draft something next week. Will sync with @evanpurkhiser, he also mentioned creating a document for common RTL pitfalls and use cases.

@matejminar matejminar merged commit 5911ca3 into master Oct 29, 2021
@matejminar matejminar deleted the ref/rtl-waitForElementToBeRemoved branch October 29, 2021 08:38
@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants