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

[EuiToolTip, useInnerText] Use jest.useFakeTimers for flaky tests #4605

Merged
merged 3 commits into from
Mar 5, 2021

Conversation

thompsongl
Copy link
Contributor

@thompsongl thompsongl commented Mar 3, 2021

Summary

Replace sleep with jest.useFakeTimers and jest.advanceTimersByTime.

Hoping to fix the often-seen flaky test failure related to EuiToolTip focus timeout:

12:45:48 FAIL src/components/tool_tip/tool_tip.test.tsx
12:45:48 ● EuiToolTip › shows tooltip on focus
12:45:48
12:45:48 expect(received).toMatchSnapshot()
12:45:48
12:45:48 Snapshot name: EuiToolTip shows tooltip on focus 1
12:45:48
12:45:48 - Snapshot
12:45:48 + Received
12:45:48
12:45:48 <span
12:45:48 class="euiToolTipAnchor"
12:45:48 >
12:45:48 <button
12:45:48 - aria-describedby="id"
12:45:48 data-test-subj="trigger"
12:45:48 >
12:45:48 Trigger
12:45:48
12:45:48
12:45:48
12:45:48 49 | trigger.simulate('focus');
12:45:48 50 | await sleep(260); // wait for showToolTip setTimout
12:45:48 > 51 | expect(takeMountedSnapshot(component)).toMatchSnapshot();
12:45:48 | ^
12:45:48 52 | });

Also closes #3249

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in Chrome, Safari, Edge, and Firefox
- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for the any docs examples

  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately

- [ ] Checked for accessibility including keyboard-only and screenreader modes
- [ ] A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4605/

@thompsongl thompsongl marked this pull request as ready for review March 3, 2021 21:16
@thompsongl thompsongl changed the title [EuiToolTip] Use jest.useFakeTimers for flaky test [EuiToolTip, useInnerText] Use jest.useFakeTimers for flaky tests Mar 3, 2021
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4605/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Changes LGTM, passing CI indicates this is at very least not worse 😄 (& I agree it should be better)

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.

[useInnerText] Flakey test
3 participants