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
fix: Conformance tests should unmount components #21423
Conversation
Enzyme does not unmount automatically at the end of a test test suite which leads to cryptic bugs when queryselectors return multiple elements, or the wrong element.
@@ -254,6 +255,7 @@ export const defaultTests: TestObject = { | |||
const defaultEl = customMount(<Component {...requiredProps} />); | |||
const defaultComponent = getComponent(defaultEl, helperComponents, wrapperComponent); | |||
const defaultClassNames = defaultComponent.getDOMNode().getAttribute('class')?.split(' ') || []; | |||
defaultEl.unmount(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The odd test that calls mount
more than once. This kind of test cannot be used with a 'global' mount.
I think this is 🤮 but can't think of a better, idea. Suggestions welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit confused, where's the other call? Also not quite understanding what the problem is (but I also don't have a deep understanding of how mount
works without attachTo
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a mountWithCleanup
module which is generally how the enzyme community seems to handle the unmounting, however that solution breaks down when mount
is used more than once in a test.
Unfortunately, this is the only time in all conformance tests this is done. The alternative would be to explicitly unmount in each test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah now I see the second mount
below this one. I'm still not convinced this is a problem given that the test is comparing classNames in two different cases, but theoretically you could do the same thing by mounting the component once and updating props. Or to be certain of avoiding interference/retained state, maybe the test could mount both versions at once inside a fragment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's a good shout, I'll try to update the test to use a single mount
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8484c3f:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: d8fe0da13e1d34028a51e5d740e7bdc78c3a6862 (build) |
📊 Bundle size reportUnchanged fixtures
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
wrapper = enzymeWrapper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it's not assignable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enzyme mount
is generic, which takes the props of the component passed in. SInce the wrapper
is never exported or returned I decided not to recreate all those generic types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you cast instead of ts-ignore so it's less "nuclear"?
This is really "strange" fix, but it's how Enzyme works unfortunately. Another one reason to rewrite these tests away from Enzyme. |
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
ContextualMenu | mount | 14626 | 7283 | 1000 | Possible regression |
All results
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 778 | 769 | 5000 | |
BaseButton | mount | 746 | 792 | 5000 | |
Breadcrumb | mount | 2288 | 2090 | 1000 | |
ButtonNext | mount | 442 | 451 | 5000 | |
Checkbox | mount | 1352 | 1291 | 5000 | |
CheckboxBase | mount | 1049 | 1131 | 5000 | |
ChoiceGroup | mount | 3989 | 3813 | 5000 | |
ComboBox | mount | 849 | 868 | 1000 | |
CommandBar | mount | 8902 | 9069 | 1000 | |
ContextualMenu | mount | 14626 | 7283 | 1000 | Possible regression |
DefaultButton | mount | 990 | 1014 | 5000 | |
DetailsRow | mount | 3265 | 3259 | 5000 | |
DetailsRowFast | mount | 3246 | 3240 | 5000 | |
DetailsRowNoStyles | mount | 3088 | 3154 | 5000 | |
Dialog | mount | 2216 | 2219 | 1000 | |
DocumentCardTitle | mount | 154 | 166 | 1000 | |
Dropdown | mount | 2770 | 2787 | 5000 | |
FluentProviderNext | mount | 1712 | 1815 | 5000 | |
FluentProviderWithTheme | mount | 150 | 160 | 10 | |
FluentProviderWithTheme | virtual-rerender | 95 | 99 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 168 | 146 | 10 | |
FocusTrapZone | mount | 1596 | 1611 | 5000 | |
FocusZone | mount | 1600 | 1556 | 5000 | |
IconButton | mount | 1531 | 1518 | 5000 | |
Label | mount | 324 | 326 | 5000 | |
Layer | mount | 2571 | 2568 | 5000 | |
Link | mount | 454 | 426 | 5000 | |
MakeStyles | mount | 1481 | 1459 | 50000 | |
MenuButton | mount | 1310 | 1287 | 5000 | |
MessageBar | mount | 1731 | 1743 | 5000 | |
Nav | mount | 2796 | 2847 | 1000 | |
OverflowSet | mount | 975 | 972 | 5000 | |
Panel | mount | 2161 | 2164 | 1000 | |
Persona | mount | 776 | 750 | 1000 | |
Pivot | mount | 1262 | 1257 | 1000 | |
PrimaryButton | mount | 1143 | 1121 | 5000 | |
Rating | mount | 6603 | 6596 | 5000 | |
SearchBox | mount | 1160 | 1188 | 5000 | |
Shimmer | mount | 2182 | 2165 | 5000 | |
Slider | mount | 1724 | 1708 | 5000 | |
SpinButton | mount | 4338 | 4326 | 5000 | |
Spinner | mount | 389 | 398 | 5000 | |
SplitButton | mount | 2748 | 2726 | 5000 | |
Stack | mount | 464 | 465 | 5000 | |
StackWithIntrinsicChildren | mount | 1975 | 1991 | 5000 | |
StackWithTextChildren | mount | 4510 | 4488 | 5000 | |
SwatchColorPicker | mount | 9910 | 9745 | 5000 | |
TagPicker | mount | 2296 | 2271 | 5000 | |
TeachingBubble | mount | 11293 | 11395 | 5000 | |
Text | mount | 385 | 395 | 5000 | |
TextField | mount | 1221 | 1212 | 5000 | |
ThemeProvider | mount | 1018 | 1037 | 5000 | |
ThemeProvider | virtual-rerender | 546 | 555 | 5000 | |
ThemeProvider | virtual-rerender-with-unmount | 1595 | 1641 | 5000 | |
Toggle | mount | 707 | 706 | 5000 | |
buttonNative | mount | 133 | 138 | 5000 |
Perf Analysis (@fluentui/react-northstar
)
Perf tests with no regressions
Scenario | Current PR Ticks | Baseline Ticks | Ratio |
---|---|---|---|
ReactionMinimalPerf.default | 340 | 319 | 1.07:1 |
ChatDuplicateMessagesPerf.default | 262 | 248 | 1.06:1 |
TableMinimalPerf.default | 357 | 338 | 1.06:1 |
BoxMinimalPerf.default | 309 | 295 | 1.05:1 |
LayoutMinimalPerf.default | 320 | 305 | 1.05:1 |
RefMinimalPerf.default | 209 | 200 | 1.05:1 |
ButtonSlotsPerf.default | 476 | 457 | 1.04:1 |
ChatMinimalPerf.default | 645 | 622 | 1.04:1 |
ImageMinimalPerf.default | 325 | 313 | 1.04:1 |
TextMinimalPerf.default | 301 | 290 | 1.04:1 |
TextAreaMinimalPerf.default | 440 | 423 | 1.04:1 |
AlertMinimalPerf.default | 236 | 230 | 1.03:1 |
CarouselMinimalPerf.default | 405 | 394 | 1.03:1 |
ListMinimalPerf.default | 449 | 438 | 1.03:1 |
RadioGroupMinimalPerf.default | 393 | 381 | 1.03:1 |
StatusMinimalPerf.default | 589 | 572 | 1.03:1 |
TreeMinimalPerf.default | 682 | 665 | 1.03:1 |
VideoMinimalPerf.default | 561 | 547 | 1.03:1 |
AvatarMinimalPerf.default | 172 | 169 | 1.02:1 |
CardMinimalPerf.default | 479 | 470 | 1.02:1 |
DropdownManyItemsPerf.default | 574 | 563 | 1.02:1 |
FormMinimalPerf.default | 345 | 337 | 1.02:1 |
GridMinimalPerf.default | 298 | 293 | 1.02:1 |
LabelMinimalPerf.default | 334 | 329 | 1.02:1 |
ListCommonPerf.default | 538 | 527 | 1.02:1 |
SliderMinimalPerf.default | 1433 | 1410 | 1.02:1 |
TreeWith60ListItems.default | 153 | 150 | 1.02:1 |
AccordionMinimalPerf.default | 137 | 136 | 1.01:1 |
AnimationMinimalPerf.default | 465 | 461 | 1.01:1 |
ButtonOverridesMissPerf.default | 1440 | 1427 | 1.01:1 |
ChatWithPopoverPerf.default | 320 | 318 | 1.01:1 |
DatepickerMinimalPerf.default | 4718 | 4661 | 1.01:1 |
DialogMinimalPerf.default | 656 | 650 | 1.01:1 |
DropdownMinimalPerf.default | 2566 | 2551 | 1.01:1 |
FlexMinimalPerf.default | 254 | 251 | 1.01:1 |
ListNestedPerf.default | 479 | 474 | 1.01:1 |
LoaderMinimalPerf.default | 587 | 582 | 1.01:1 |
MenuButtonMinimalPerf.default | 1420 | 1404 | 1.01:1 |
SplitButtonMinimalPerf.default | 3646 | 3625 | 1.01:1 |
TableManyItemsPerf.default | 1621 | 1600 | 1.01:1 |
CustomToolbarPrototype.default | 3479 | 3450 | 1.01:1 |
AttachmentSlotsPerf.default | 901 | 897 | 1:1 |
CheckboxMinimalPerf.default | 2277 | 2282 | 1:1 |
EmbedMinimalPerf.default | 3490 | 3482 | 1:1 |
HeaderSlotsPerf.default | 645 | 644 | 1:1 |
InputMinimalPerf.default | 1102 | 1100 | 1:1 |
ListWith60ListItems.default | 548 | 546 | 1:1 |
PopupMinimalPerf.default | 522 | 524 | 1:1 |
ProviderMinimalPerf.default | 964 | 961 | 1:1 |
SkeletonMinimalPerf.default | 301 | 301 | 1:1 |
ToolbarMinimalPerf.default | 792 | 795 | 1:1 |
HeaderMinimalPerf.default | 304 | 308 | 0.99:1 |
ItemLayoutMinimalPerf.default | 1006 | 1012 | 0.99:1 |
MenuMinimalPerf.default | 712 | 717 | 0.99:1 |
ProviderMergeThemesPerf.default | 1464 | 1473 | 0.99:1 |
TooltipMinimalPerf.default | 872 | 882 | 0.99:1 |
SegmentMinimalPerf.default | 295 | 302 | 0.98:1 |
IconMinimalPerf.default | 501 | 511 | 0.98:1 |
ButtonMinimalPerf.default | 146 | 150 | 0.97:1 |
DividerMinimalPerf.default | 302 | 311 | 0.97:1 |
RosterPerf.default | 993 | 1022 | 0.97:1 |
PortalMinimalPerf.default | 146 | 153 | 0.95:1 |
AttachmentMinimalPerf.default | 126 | 135 | 0.93:1 |
closing since #21664 also addresses this |
Enzyme does not unmount automatically at the end of a test
test suite which leads to cryptic bugs when queryselectors return
multiple elements, or the wrong element.
Current Behavior
Conformance tests leave DOM elements in the document after test
New Behavior
Conformance tests don't leave DOM elements in the document after test
Related Issue(s)
Fixes #