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

Fix act() tests by properly unmounting the container #14974

Merged
merged 1 commit into from
Apr 12, 2019

Conversation

philipp-spiess
Copy link
Contributor

While playing around with the new act() API I discovered a test that
was unexpectedly failing. After some digging I noticed that the test is
passing when run in isolation and that the test suite can be fixe by
properly calling ReactDOM.unmountComponentAtNode() to clean up after
every test run.

You can reproduce the issue by simply commenting out the call to
unmountComponentAtNode in the afterEach callback. The newly added
test will fail but pass in isolation.

I thought it would be a good idea to fix this upstream so nobody runs
into this issue again.

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

I moving all the act tests to its own file, so I'll be sure to put this in that too. approving for now, but I'll merge it in once I have the async act stuff ready. thanks!

@@ -678,6 +665,39 @@ describe('ReactTestUtils', () => {
);
});

it('flushes immediate re-renders with act but advances timers later', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

act doesn't advance timers at all, so this title is a bit wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, removed that part.

@philipp-spiess
Copy link
Contributor Author

@threepointone Rebased my PR but the issue I noticed earlier is no longer happening (the missing ReactDOM.unmountComponentAtNode() no longer causes differences in behavior - Which is great!). Let me know if you think the test case adds value and if we should get the changes in.

@threepointone
Copy link
Contributor

Thank you, it just slipped my mind! I do think your structure is better, I'll merge it in today.

@sizebot
Copy link

sizebot commented Apr 12, 2019

React: size: -0.4%, gzip: 🔺+0.4%

ReactDOM: size: -1.4%, gzip: -0.8%

Details of bundled changes.

Comparing: 543353a...d16f798

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js +5.8% +3.0% 101.43 KB 107.28 KB 26.32 KB 27.11 KB UMD_DEV
react.production.min.js -0.4% 🔺+0.4% 12.06 KB 12.01 KB 4.62 KB 4.64 KB UMD_PROD
react.development.js +9.5% +4.7% 63.97 KB 70.04 KB 17.21 KB 18.02 KB NODE_DEV
react.production.min.js 🔺+0.4% 🔺+0.7% 6.42 KB 6.44 KB 2.65 KB 2.67 KB NODE_PROD
React-dev.js +9.6% +5.1% 62.31 KB 68.32 KB 16.52 KB 17.36 KB FB_WWW_DEV
React-prod.js 🔺+4.5% 🔺+3.6% 15.33 KB 16.02 KB 4.09 KB 4.24 KB FB_WWW_PROD
React-profiling.js +4.5% +3.6% 15.33 KB 16.02 KB 4.09 KB 4.24 KB FB_WWW_PROFILING
react.profiling.min.js -0.3% +0.9% 14.21 KB 14.17 KB 5.13 KB 5.18 KB UMD_PROFILING

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.9% +0.2% 816.03 KB 809.01 KB 184.59 KB 184.88 KB UMD_DEV
react-dom.production.min.js -1.4% -0.8% 105.16 KB 103.68 KB 33.96 KB 33.69 KB UMD_PROD
react-dom.development.js -0.9% +0.2% 810.42 KB 803.5 KB 182.98 KB 183.33 KB NODE_DEV
react-dom.production.min.js -1.4% -1.0% 105.14 KB 103.67 KB 33.47 KB 33.14 KB NODE_PROD
react-dom-test-utils.development.js +4.2% +6.5% 51.99 KB 54.19 KB 14.07 KB 14.98 KB UMD_DEV
react-dom-test-utils.production.min.js 🔺+1.1% 🔺+1.9% 10.41 KB 10.52 KB 3.82 KB 3.89 KB UMD_PROD
react-dom-test-utils.development.js +4.2% +6.5% 51.71 KB 53.91 KB 14.01 KB 14.91 KB NODE_DEV
react-dom-test-utils.production.min.js 🔺+1.1% 🔺+1.9% 10.2 KB 10.31 KB 3.75 KB 3.82 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% +0.1% 60.75 KB 60.76 KB 15.83 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 🔺+0.1% 🔺+0.3% 10.68 KB 10.69 KB 3.65 KB 3.67 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% +0.1% 60.43 KB 60.43 KB 15.71 KB 15.72 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 🔺+0.1% 🔺+0.3% 10.42 KB 10.42 KB 3.55 KB 3.57 KB NODE_PROD
react-dom-server.browser.development.js +1.5% +1.2% 134.7 KB 136.73 KB 35.5 KB 35.92 KB UMD_DEV
react-dom-server.browser.production.min.js 🔺+0.3% 0.0% 19.11 KB 19.18 KB 7.21 KB 7.21 KB UMD_PROD
react-dom-server.browser.development.js +1.6% +1.3% 130.83 KB 132.86 KB 34.55 KB 34.99 KB NODE_DEV
react-dom-server.browser.production.min.js 🔺+0.3% 0.0% 19.04 KB 19.1 KB 7.2 KB 7.2 KB NODE_PROD
react-dom-server.node.development.js +1.5% +1.2% 132.77 KB 134.8 KB 35.1 KB 35.54 KB NODE_DEV
react-dom-server.node.production.min.js 🔺+0.3% -0.0% 19.9 KB 19.96 KB 7.51 KB 7.51 KB NODE_PROD
ReactDOM-dev.js -0.9% -0.0% 835.3 KB 827.66 KB 184.62 KB 184.61 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+1.2% 🔺+2.1% 331.96 KB 336 KB 61.24 KB 62.53 KB FB_WWW_PROD
ReactTestUtils-dev.js +2.9% +3.4% 49.97 KB 51.4 KB 13.38 KB 13.83 KB FB_WWW_DEV
ReactDOMServer-dev.js +1.4% +0.8% 133.13 KB 134.95 KB 34.32 KB 34.62 KB FB_WWW_DEV
ReactDOMServer-prod.js 🔺+1.4% 🔺+0.7% 46.48 KB 47.14 KB 10.72 KB 10.8 KB FB_WWW_PROD
react-dom.profiling.min.js -1.1% -0.3% 108.24 KB 107 KB 34.08 KB 34 KB NODE_PROFILING
ReactDOM-profiling.js +0.9% +1.4% 338.41 KB 341.38 KB 62.58 KB 63.46 KB FB_WWW_PROFILING
react-dom.profiling.min.js -1.2% +0.1% 108.14 KB 106.83 KB 34.61 KB 34.64 KB UMD_PROFILING
react-dom-unstable-fizz.browser.development.js +0.2% +0.8% 3.66 KB 3.66 KB 1.44 KB 1.45 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 🔺+0.5% 🔺+1.7% 1.2 KB 1.21 KB 694 B 706 B UMD_PROD
react-dom-unstable-fizz.browser.development.js +0.2% +0.6% 3.49 KB 3.49 KB 1.4 KB 1.41 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 🔺+0.6% 🔺+1.4% 1.04 KB 1.05 KB 628 B 637 B NODE_PROD
react-dom-unstable-fizz.node.development.js +0.2% +0.5% 3.73 KB 3.74 KB 1.42 KB 1.43 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 🔺+0.5% 🔺+1.2% 1.1 KB 1.1 KB 659 B 667 B NODE_PROD
react-dom-unstable-fire.development.js -0.9% +0.2% 816.35 KB 809.34 KB 184.72 KB 185.02 KB UMD_DEV
react-dom-unstable-fire.production.min.js -1.4% -0.8% 105.17 KB 103.7 KB 33.97 KB 33.7 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js -1.2% +0.1% 108.15 KB 106.85 KB 34.62 KB 34.65 KB UMD_PROFILING
react-dom-unstable-fire.development.js -0.9% +0.2% 810.74 KB 803.82 KB 183.11 KB 183.47 KB NODE_DEV
react-dom-unstable-fire.production.min.js -1.4% -1.0% 105.15 KB 103.69 KB 33.48 KB 33.15 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js -1.1% -0.3% 108.26 KB 107.01 KB 34.09 KB 34 KB NODE_PROFILING
ReactFire-dev.js -0.9% 0.0% 834.49 KB 826.85 KB 184.59 KB 184.62 KB FB_WWW_DEV
ReactFire-prod.js 🔺+1.0% 🔺+2.0% 320.62 KB 323.97 KB 58.88 KB 60.08 KB FB_WWW_PROD
ReactFire-profiling.js +0.7% +1.3% 327.02 KB 329.32 KB 60.26 KB 61.04 KB FB_WWW_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -2.2% -1.0% 568.75 KB 556.46 KB 122.69 KB 121.46 KB UMD_DEV
react-art.production.min.js -1.4% -1.2% 96.81 KB 95.49 KB 29.67 KB 29.31 KB UMD_PROD
react-art.development.js -2.4% -1.2% 499.66 KB 487.49 KB 105.34 KB 104.07 KB NODE_DEV
react-art.production.min.js -2.2% -1.5% 61.81 KB 60.46 KB 18.89 KB 18.61 KB NODE_PROD
ReactART-dev.js -2.5% -1.4% 509.59 KB 496.65 KB 104.64 KB 103.13 KB FB_WWW_DEV
ReactART-prod.js -1.2% -0.7% 197.37 KB 194.93 KB 33.38 KB 33.15 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -2.4% -1.2% 513.33 KB 500.9 KB 108.05 KB 106.78 KB UMD_DEV
react-test-renderer.production.min.js -2.2% -1.7% 63.06 KB 61.68 KB 19.25 KB 18.93 KB UMD_PROD
react-test-renderer.development.js -2.4% -1.1% 508.85 KB 496.44 KB 106.89 KB 105.68 KB NODE_DEV
react-test-renderer.production.min.js -2.2% -1.5% 62.76 KB 61.36 KB 19.08 KB 18.8 KB NODE_PROD
react-test-renderer-shallow.development.js +7.5% +9.3% 38.97 KB 41.88 KB 9.8 KB 10.71 KB UMD_DEV
react-test-renderer-shallow.production.min.js 🔺+1.8% 🔺+1.6% 11.41 KB 11.63 KB 3.5 KB 3.55 KB UMD_PROD
react-test-renderer-shallow.development.js +8.8% +11.4% 33.2 KB 36.11 KB 8.4 KB 9.36 KB NODE_DEV
react-test-renderer-shallow.production.min.js 🔺+1.8% 🔺+1.4% 11.61 KB 11.81 KB 3.62 KB 3.67 KB NODE_PROD
ReactTestRenderer-dev.js -2.5% -1.3% 520.33 KB 507.22 KB 106.77 KB 105.37 KB FB_WWW_DEV
ReactShallowRenderer-dev.js +6.4% +5.9% 32.98 KB 35.08 KB 8.24 KB 8.72 KB FB_WWW_DEV

react-noop-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-noop-renderer.development.js +2.0% +3.5% 34.44 KB 35.15 KB 8.41 KB 8.71 KB NODE_DEV
react-noop-renderer.production.min.js 🔺+2.6% 🔺+3.0% 10.22 KB 10.49 KB 3.35 KB 3.45 KB NODE_PROD
react-noop-renderer-persistent.development.js +2.0% +3.5% 34.56 KB 35.26 KB 8.43 KB 8.72 KB NODE_DEV
react-noop-renderer-persistent.production.min.js 🔺+2.5% 🔺+3.1% 10.25 KB 10.51 KB 3.36 KB 3.46 KB NODE_PROD
react-noop-renderer-server.development.js +0.3% +1.0% 1.82 KB 1.83 KB 868 B 877 B NODE_DEV
react-noop-renderer-server.production.min.js 🔺+0.7% 🔺+2.3% 807 B 813 B 480 B 491 B NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -3.0% -1.6% 499.94 KB 485.02 KB 104.17 KB 102.51 KB NODE_DEV
react-reconciler.production.min.js -2.6% -2.1% 63.05 KB 61.39 KB 18.75 KB 18.35 KB NODE_PROD
react-reconciler-persistent.development.js -3.0% -1.6% 497.83 KB 482.93 KB 103.3 KB 101.62 KB NODE_DEV
react-reconciler-persistent.production.min.js -2.6% -2.1% 63.06 KB 61.4 KB 18.75 KB 18.36 KB NODE_PROD
react-reconciler-reflection.development.js +21.6% +22.2% 15.78 KB 19.18 KB 4.9 KB 5.98 KB NODE_DEV
react-reconciler-reflection.production.min.js 🔺+2.5% 🔺+3.3% 2.37 KB 2.43 KB 1.06 KB 1.09 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -10.7% -11.5% 703.65 KB 628.2 KB 150.58 KB 133.33 KB RN_FB_DEV
ReactNativeRenderer-prod.js -1.3% -2.0% 246.94 KB 243.71 KB 43.2 KB 42.35 KB RN_FB_PROD
ReactNativeRenderer-dev.js -10.7% -11.5% 703.57 KB 628.12 KB 150.56 KB 133.29 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -1.3% -2.0% 246.95 KB 243.72 KB 43.2 KB 42.35 KB RN_OSS_PROD
ReactFabric-dev.js -10.9% -11.7% 692.5 KB 616.89 KB 147.96 KB 130.62 KB RN_FB_DEV
ReactFabric-prod.js -1.1% -2.0% 240.24 KB 237.48 KB 41.95 KB 41.09 KB RN_FB_PROD
ReactFabric-dev.js -10.9% -11.7% 692.41 KB 616.79 KB 147.91 KB 130.59 KB RN_OSS_DEV
ReactFabric-prod.js -1.1% -2.0% 240.24 KB 237.49 KB 41.94 KB 41.09 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -0.4% -1.4% 252.97 KB 251.91 KB 44.52 KB 43.92 KB RN_OSS_PROFILING
ReactFabric-profiling.js -0.2% -1.3% 245.54 KB 245.14 KB 43.28 KB 42.7 KB RN_OSS_PROFILING
ReactNativeRenderer-profiling.js -0.4% -1.4% 252.95 KB 251.89 KB 44.52 KB 43.92 KB RN_FB_PROFILING
ReactFabric-profiling.js -0.2% -1.3% 245.53 KB 245.13 KB 43.29 KB 42.7 KB RN_FB_PROFILING

scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
scheduler.development.js -0.9% -0.8% 22.96 KB 22.75 KB 5.88 KB 5.83 KB NODE_DEV
scheduler.production.min.js -1.2% 🔺+1.6% 4.78 KB 4.72 KB 1.77 KB 1.8 KB NODE_PROD
Scheduler-dev.js -1.0% -0.9% 23.2 KB 22.97 KB 5.92 KB 5.87 KB FB_WWW_DEV
Scheduler-prod.js 🔺+0.1% 🔺+1.1% 13.7 KB 13.71 KB 2.77 KB 2.8 KB FB_WWW_PROD
scheduler-tracing.development.js -0.1% +0.1% 10.8 KB 10.79 KB 2.62 KB 2.62 KB NODE_DEV
scheduler-tracing.production.min.js 🔺+0.8% 🔺+3.2% 722 B 728 B 372 B 384 B NODE_PROD
scheduler-tracing.profiling.min.js +0.2% +1.3% 3.26 KB 3.26 KB 987 B 1000 B NODE_PROFILING
SchedulerTracing-dev.js -2.1% -5.1% 10.22 KB 10.01 KB 2.21 KB 2.09 KB FB_WWW_DEV
scheduler-unstable_mock.development.js -1.2% -1.2% 17.51 KB 17.3 KB 4.03 KB 3.98 KB NODE_DEV
scheduler-unstable_mock.production.min.js -1.5% 🔺+1.4% 4.08 KB 4.02 KB 1.57 KB 1.59 KB NODE_PROD
SchedulerMock-dev.js -1.3% -1.4% 17.74 KB 17.51 KB 4.08 KB 4.02 KB FB_WWW_DEV
SchedulerMock-prod.js 🔺+0.5% 🔺+0.8% 11.8 KB 11.86 KB 2.42 KB 2.43 KB FB_WWW_PROD

react-events

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-events.development.js +45.3% +14.9% 990 B 1.4 KB 545 B 626 B NODE_DEV
react-events.production.min.js 🔺+37.9% 🔺+16.6% 506 B 698 B 343 B 400 B NODE_PROD
ReactEvents-dev.js +47.1% +12.7% 956 B 1.37 KB 536 B 604 B FB_WWW_DEV
ReactEvents-prod.js 🔺+66.7% 🔺+18.0% 687 B 1.12 KB 410 B 484 B FB_WWW_PROD
react-events.development.js +37.9% +13.6% 1.16 KB 1.59 KB 605 B 687 B UMD_DEV
react-events.production.min.js 🔺+26.8% 🔺+13.6% 676 B 857 B 420 B 477 B UMD_PROD
react-events-press.development.js +98.1% +85.3% 10.08 KB 19.98 KB 2.57 KB 4.76 KB UMD_DEV
react-events-press.production.min.js 🔺+96.1% 🔺+79.4% 3.96 KB 7.77 KB 1.47 KB 2.64 KB UMD_PROD
react-events-press.development.js +99.8% +87.2% 9.91 KB 19.81 KB 2.52 KB 4.72 KB NODE_DEV
react-events-press.production.min.js 🔺+100.1% 🔺+82.6% 3.8 KB 7.6 KB 1.42 KB 2.59 KB NODE_PROD
ReactEventsPress-dev.js +76.9% +56.0% 10.23 KB 18.11 KB 2.57 KB 4.02 KB FB_WWW_DEV
ReactEventsPress-prod.js 🔺+91.8% 🔺+59.4% 7.81 KB 14.98 KB 1.86 KB 2.96 KB FB_WWW_PROD
react-events-hover.development.js +44.0% +38.1% 5.15 KB 7.41 KB 1.38 KB 1.91 KB UMD_DEV
react-events-hover.production.min.js 🔺+44.5% 🔺+34.1% 2.26 KB 3.26 KB 923 B 1.21 KB UMD_PROD
react-events-hover.development.js +45.5% +39.4% 4.98 KB 7.24 KB 1.34 KB 1.87 KB NODE_DEV
react-events-hover.production.min.js 🔺+47.9% 🔺+37.1% 2.1 KB 3.1 KB 865 B 1.16 KB NODE_PROD
ReactEventsHover-dev.js +48.6% +38.8% 4.99 KB 7.42 KB 1.35 KB 1.88 KB FB_WWW_DEV
ReactEventsHover-prod.js 🔺+52.0% 🔺+38.7% 4.18 KB 6.35 KB 1.1 KB 1.53 KB FB_WWW_PROD
react-events-focus.development.js -3.5% +0.9% 3.37 KB 3.25 KB 1.09 KB 1.1 KB UMD_DEV
react-events-focus.production.min.js -2.7% -1.2% 1.53 KB 1.49 KB 721 B 712 B UMD_PROD
react-events-focus.development.js -3.7% +0.2% 3.2 KB 3.08 KB 1.04 KB 1.04 KB NODE_DEV
react-events-focus.production.min.js -3.0% -2.3% 1.36 KB 1.32 KB 659 B 644 B NODE_PROD
ReactEventsFocus-dev.js -5.3% -1.3% 3.17 KB 3 KB 1.03 KB 1.02 KB FB_WWW_DEV
ReactEventsFocus-prod.js -10.1% -6.7% 2.49 KB 2.24 KB 827 B 772 B FB_WWW_PROD
react-events-swipe.development.js -0.3% +0.7% 8.28 KB 8.25 KB 2.54 KB 2.56 KB UMD_DEV
react-events-swipe.production.min.js 0.0% 🔺+0.8% 3.45 KB 3.45 KB 1.59 KB 1.6 KB UMD_PROD
react-events-swipe.development.js -0.3% +0.6% 8.11 KB 8.08 KB 2.51 KB 2.53 KB NODE_DEV
react-events-swipe.production.min.js 0.0% 🔺+0.6% 3.29 KB 3.29 KB 1.53 KB 1.54 KB NODE_PROD
ReactEventsSwipe-dev.js -0.6% +0.4% 6.21 KB 6.17 KB 1.77 KB 1.78 KB FB_WWW_DEV
ReactEventsSwipe-prod.js -0.1% 🔺+0.6% 5.95 KB 5.94 KB 1.53 KB 1.54 KB FB_WWW_PROD
react-events-drag.development.js +2.9% +1.8% 7.55 KB 7.77 KB 2.39 KB 2.43 KB UMD_DEV
react-events-drag.production.min.js 🔺+3.0% 🔺+2.8% 3.2 KB 3.3 KB 1.45 KB 1.49 KB UMD_PROD
react-events-drag.development.js +2.9% +1.8% 7.38 KB 7.6 KB 2.36 KB 2.4 KB NODE_DEV
react-events-drag.production.min.js 🔺+3.1% 🔺+2.6% 3.04 KB 3.13 KB 1.4 KB 1.43 KB NODE_PROD
ReactEventsDrag-dev.js +5.0% +2.7% 5.57 KB 5.85 KB 1.64 KB 1.69 KB FB_WWW_DEV
ReactEventsDrag-prod.js 🔺+5.2% 🔺+3.7% 5.12 KB 5.39 KB 1.34 KB 1.38 KB FB_WWW_PROD

Generated by 🚫 dangerJS

@threepointone
Copy link
Contributor

lol @sizebot go home, you're drunk

@threepointone threepointone merged commit a30e7d9 into facebook:master Apr 12, 2019
@gaearon
Copy link
Collaborator

gaearon commented Apr 13, 2019

@threepointone For the future — it's a good idea to always do cleanup in afterEach because you want to clean up even if a test failed and didn't reach the end.

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