-
Notifications
You must be signed in to change notification settings - Fork 10
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
[RW-7610][risk=no] Unmount enzyme React components after each test case #5961
Conversation
ee6fb6c
to
4d2ddae
Compare
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.
This is awesome. Until now, I don't think my local UI test suite has fully passed since Angular. (Individual tests were fine, which makes sense)
ui/src/setupTests.js
Outdated
@@ -8,13 +8,13 @@ require('mutationobserver-shim'); | |||
*/ | |||
const enzyme = require("enzyme"); | |||
const Adapter = require("enzyme-adapter-react-16"); | |||
const reactDOM = require("react-dom"); |
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.
this appears to be unused
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.
no change when I comment this out
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.
Oops, thanks. This was leftover from the previous approach
aa4a0fa
to
dbb8191
Compare
I've filed https://precisionmedicineinitiative.atlassian.net/browse/RW-7617 to track the ongoing Puppeteer notebook failures. These are completely unrelated to this PR, which only affects UI unit test code and has no bearing on the UI code itself, or the e2e tests. |
(FYI I retried 4x, see https://app.circleci.com/pipelines/github/all-of-us/workbench?branch=ch%2Fui-test-deflake) |
Turns out there is no automated teardown of enzyme provided by our test harness after each test case, per enzymejs/enzyme#911
The solution described above caused some complications, as using a common DOM root caused an additional unmount on every
mount()
call within the same test case. It's possible that fixing the issues that arise there would be a more pure solution, but it would likely require retrofitting a bunch of our components.Specifically, it would result in this error when attempting to reattach the component:
This change results in a large decrease in test latency for me locally and specifically reduced data-access-requirements test case runtime significantly, which were seemingly flaking due to large callback cruft build-up. From a few data points on circle appears to reduce test time by about half:
~2m50s -> ~1m20s