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

test(ui): Convert DropdownLink tests to RTL and TS #39322

Merged
merged 4 commits into from
Sep 27, 2022

Conversation

malwilley
Copy link
Member

No description provided.

@malwilley malwilley requested a review from a team September 27, 2022 00:46
@malwilley malwilley requested a review from a team as a code owner September 27, 2022 00:46
@malwilley malwilley removed the request for review from a team September 27, 2022 00:47
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 27, 2022
static/app/components/dropdownLink.spec.tsx Outdated Show resolved Hide resolved
static/app/components/dropdownLink.spec.tsx Outdated Show resolved Hide resolved
static/app/components/dropdownLink.spec.tsx Outdated Show resolved Hide resolved
static/app/components/dropdownLink.spec.tsx Outdated Show resolved Hide resolved
static/app/components/dropdownLink.spec.tsx Outdated Show resolved Hide resolved
});

it('does not close when document is clicked', function () {
jest.useFakeTimers();
Copy link
Member

Choose a reason for hiding this comment

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

would it be fine if instead of using jest.useFakeTimers and jest.runAllTimers(), we would just wait for the element by using await screen.find*?

Copy link
Member Author

Choose a reason for hiding this comment

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

We still want to use jest.useFakeTimers() so the test can finish as fast as possible, but I just learned that the async utilities do advance fake timers which is great: testing-library/dom-testing-library#661

So I kept the fake timers and removed all the runAllTimers() calls

@malwilley malwilley merged commit 810725e into master Sep 27, 2022
@malwilley malwilley deleted the malwilley/test/rtl-dropdownlink branch September 27, 2022 18:21
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants