Skip to content

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

Merged
thompsongl merged 3 commits intoelastic:masterfrom
thompsongl:hotfix/tooltip-test-timer
Mar 5, 2021
Merged

[EuiToolTip, useInnerText] Use jest.useFakeTimers for flaky tests#4605
thompsongl merged 3 commits intoelastic:masterfrom
thompsongl:hotfix/tooltip-test-timer

Conversation

@thompsongl
Copy link
Copy Markdown
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

@thompsongl thompsongl requested a review from chandlerprall March 3, 2021 19:28
@kibanamachine
Copy link
Copy Markdown

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
Copy Markdown

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

@thompsongl thompsongl added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label Mar 4, 2021
Copy link
Copy Markdown
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

Labels

skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[useInnerText] Flakey test

3 participants