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

Tests: Fix spurious infinite timer issue #12174

Merged
merged 4 commits into from Mar 4, 2020
Merged

Tests: Fix spurious infinite timer issue #12174

merged 4 commits into from Mar 4, 2020

Conversation

JasonGore
Copy link
Member

@JasonGore JasonGore commented Mar 3, 2020

Pull request checklist

  • Addresses an existing issue: Fixes #0000
  • Include a change request file using $ yarn change

Description of changes

Fix spurious infinite timer issue on unit tests due to an issue with jest's runAllTimers and debounce implementations by adding a mock implementation for Async.debounce, similar to the mock for lodash debounce.

image

I was able to repro the issue by forcibly calling Async.debounce in a unit test, like so:

+import { Async } from '../../Utilities';
 import { mount, ReactWrapper } from 'enzyme';
 import { renderToStaticMarkup } from 'react-dom/server';
 
@@ -412,6 +414,13 @@ describe('TextField with error message', () => {
 
     assertErrorMessage(wrapper.getDOMNode(), errorMessage);
 
+    const AsyncInstance = new Async();
+    const DebounceResultFn2 = AsyncInstance.debounce(() => {
+      console.log('debounced');
+    }, 1000);
+
+    DebounceResultFn2();
+
     wrapper.setProps({ value: '' });
     jest.runAllTimers();

And confirmed that this mock fixed the issue.

Search terms: Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...

Microsoft Reviewers: Open in CodeFlow

@JasonGore JasonGore changed the title Tests: Add mock for Async to prevent spurious infinite timer issue. Tests: Fix spurious infinite timer issue Mar 3, 2020
@msft-github-bot
Copy link
Contributor

msft-github-bot commented Mar 4, 2020

Perf Analysis

No significant results to display.

All results

Scenario Master Ticks PR Ticks Status
BaseButton 695 707
BaseButton (experiments) 927 918
DefaultButton 972 949
DefaultButton (experiments) 1917 1866
DetailsRow 3259 3458
DetailsRow (fast icons) 3242 3230
DetailsRow without styles 3179 3039
DocumentCardTitle with truncation 1499 1498
MenuButton 1272 1296
MenuButton (experiments) 3376 3502
PrimaryButton 1127 1104
PrimaryButton (experiments) 1864 1855
SplitButton 2731 2718
SplitButton (experiments) 6634 6483
Stack 450 456
Stack with Intrinsic children 1098 1068
Stack with Text children 4018 4157
Text 371 352
Toggle 775 776
Toggle (experiments) 2136 2076
button 54 60

Perf Analysis (Fluent)

Perf comparison
Status Scenario Fluent TPI Fabric TPI Ratio Iterations Ticks
🔧 Avatar.Fluent 0.51 0.49 1.04:1 2000 1022
🎯 Button.Fluent 0.16 0.23 0.7:1 1000 159
🔧 Checkbox.Fluent 0.93 0.4 2.33:1 1000 925
🔧 Dialog.Fluent 0.36 0.25 1.44:1 5000 1818
🔧 Dropdown.Fluent 3.52 0.49 7.18:1 1000 3517
🔧 Icon.Fluent 0.17 0.05 3.4:1 5000 839
🦄 Image.Fluent 0.06 0.1 0.6:1 5000 321
🔧 Slider.Fluent 1.5 0.41 3.66:1 1000 1498
🔧 Text.Fluent 0.07 0.02 3.5:1 5000 366
🦄 Tooltip.Fluent 0.13 13.13 0.01:1 5000 627

🔧 Needs work     🎯 On target     🦄 Amazing

Perf tests with no regressions
Scenario Current PR Ticks Baseline Ticks Ratio
ButtonMinimalPerf.default 164 135 1.21:1
HierarchicalTreeMinimalPerf.default 1235 1085 1.14:1
ListWith60ListItems.default 183 166 1.1:1
TextAreaMinimalPerf.default 3492 3230 1.08:1
ChatWithPopoverPerf.default 606 569 1.07:1
GridMinimalPerf.default 921 860 1.07:1
Text.Fluent 366 343 1.07:1
ChatDuplicateMessagesPerf.default 435 411 1.06:1
LabelMinimalPerf.default 366 350 1.05:1
Checkbox.Fluent 925 878 1.05:1
Tooltip.Fluent 627 599 1.05:1
HeaderSlotsPerf.default 1888 1808 1.04:1
ImageMinimalPerf.default 332 319 1.04:1
ReactionMinimalPerf.default 2533 2440 1.04:1
EmbedMinimalPerf.default 6341 6175 1.03:1
BoxMinimalPerf.default 339 331 1.02:1
DialogMinimalPerf.default 1895 1857 1.02:1
FlexMinimalPerf.default 279 274 1.02:1
HeaderMinimalPerf.default 599 586 1.02:1
ItemLayoutMinimalPerf.default 2223 2181 1.02:1
ListCommonPerf.default 968 948 1.02:1
PortalMinimalPerf.default 300 294 1.02:1
StatusMinimalPerf.default 322 316 1.02:1
TooltipMinimalPerf.default 869 854 1.02:1
TreeWith60ListItems.default 221 216 1.02:1
VideoMinimalPerf.default 944 922 1.02:1
Dropdown.Fluent 3517 3432 1.02:1
Image.Fluent 321 314 1.02:1
AccordionMinimalPerf.default 239 236 1.01:1
AttachmentSlotsPerf.default 3475 3442 1.01:1
AvatarMinimalPerf.default 542 535 1.01:1
DropdownMinimalPerf.default 3571 3526 1.01:1
IconMinimalPerf.default 390 388 1.01:1
ProviderMergeThemesPerf.default 1282 1273 1.01:1
SegmentMinimalPerf.default 1179 1163 1.01:1
SplitButtonMinimalPerf.default 12605 12437 1.01:1
TreeMinimalPerf.default 1238 1225 1.01:1
Avatar.Fluent 1022 1008 1.01:1
FormMinimalPerf.default 984 984 1:1
InputMinimalPerf.default 1087 1082 1:1
MenuButtonMinimalPerf.default 1958 1952 1:1
PopupMinimalPerf.default 418 417 1:1
ProviderMinimalPerf.default 619 622 1:1
ToolbarMinimalPerf.default 1172 1173 1:1
Dialog.Fluent 1818 1811 1:1
Slider.Fluent 1498 1493 1:1
ButtonSlotsPerf.default 737 741 0.99:1
ChatMinimalPerf.default 558 565 0.99:1
DropdownManyItemsPerf.default 367 371 0.99:1
RefMinimalPerf.default 195 197 0.99:1
CustomToolbarPrototype.default 3647 3673 0.99:1
Button.Fluent 159 160 0.99:1
Icon.Fluent 839 850 0.99:1
AnimationMinimalPerf.default 666 681 0.98:1
CarouselMinimalPerf.default 1961 2008 0.98:1
LayoutMinimalPerf.default 680 696 0.98:1
ListMinimalPerf.default 411 421 0.98:1
ListNestedPerf.default 899 919 0.98:1
MenuMinimalPerf.default 2008 2049 0.98:1
RadioGroupMinimalPerf.default 609 623 0.98:1
SliderMinimalPerf.default 1489 1521 0.98:1
AlertMinimalPerf.default 595 617 0.96:1
CheckboxMinimalPerf.default 4077 4251 0.96:1
LoaderMinimalPerf.default 999 1045 0.96:1
TextMinimalPerf.default 377 391 0.96:1
TableMinimalPerf.default 687 726 0.95:1
AttachmentMinimalPerf.default 873 924 0.94:1
DividerMinimalPerf.default 1085 1199 0.9:1

@size-auditor
Copy link

size-auditor bot commented Mar 4, 2020

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: f67e451385d5e18b0a704b1be91bc48c1beb78af (build)

Copy link
Member

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

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

Nice! Just one minor comment.

@JasonGore JasonGore merged commit 63f77b6 into microsoft:master Mar 4, 2020
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.

None yet

5 participants