[tests] leaking memory, tests silently failing, intermittent failures in CI #1143
Labels
has internal tracking issue
issues that have a link to an issue on the internal IBM tracking/reporting repository
released
type: bug 🐛
Milestone
Internal Watson-IoT/pal-tracking#400
Describe the bug
We're continuing to see intermittent test failures both locally and in CI. Tests unrelated to a current change set will fail, and then pass on re-run.
Following this write up, Running
yarn test:base --logHeapUsage --silent --runInBand --no-cache
provides a very clear output showing our tests are leaking memory. Heap size grows with each test instead of being relatively flat. Something is preventing tests from being garbage collected after they pass.Click to expand the resulting console output
Additionally there is an error present in the console:
Its from
HierarchyList.test.jsx
. Specifically, the two tests usingwaitForElementToBeRemoved
are not resolved, the element is never removed. The promise is rejected, but the error is swallowed because we do not.catch()
it, so the tests pass.The HierarchyList uses lodash's
debounce
which doesn't play nicely with jest'suseFakeTimers
. In addition, we can't just mock it to return the function given because we need to actually test the functionality. You search - 150ms later, the dom is updated with the reduced search list.I think these two things are related. There's a ton of issues in the jest repo on memory leaks, but the first place to start is to ensure the environment is properly configured.
From there, we then ensure the following:
Items to fix
--detectLeaks
is broken in Jest 25, there is a PR though.beforeEach
/beforeAll
block that is within adescribe
block. All should have a restore of the original function/module within anafterEach
/afterAll
.jest.useFakeTimers()
Breadcrumb.test.jsx
Table.test.jsx
The text was updated successfully, but these errors were encountered: