memlab
memlab copied to clipboard
Discussion: How to run memlab on a test suite.
It's all in the title, we are running tests with Testing Library + MSW on Jest and with some legacy jest mocks. The pipeline looks a bit flaky on the CI and we'd like to rule out memory leaks by running memlab on the existing test suite as opposed to creating a scenario and re-write all the test base.
Is there any chance to achieve this with the current implementation? The get started doc seemed that you need to boot up the app and run scenario to find leaks by headlessly browsing the app as opposed to running existing tests.
@SimonGodefroid Can you share an example of what your current test looks like, does your test create its own Puppeteer page object and interact with it?
Hey @JacksonGL so I don't have an example to share unfortunately because our company's code is closed source but essentially we run tests with Jest + React Testing Library. I guess my question is outside of the current working principles of Memlab
essentially I'm asking whether there'll be a way to for instance:
$ memlab "yarn test"
Where yarn test
is your test script command e.g. react-scripts test
and then Memlab
would be able to track down leaks by relying on the test suite rendering the app as opposed to going through Puppeteer.
Essentially finding a memory leak on a repo would be something that you run against an existing test base (if possible) as opposed to having to setup a new tool. Then it might not be doable. I kinda thought Memlab would do what --detectOpenHandles
does but super charged and without having to setup anything new.
@SimonGodefroid --detectOpenHandles
in Jest was using async_hooks
from node.js. E2E test framework like puppeteer doesn't seem to provide a callback to instrument navigation in SPA (let me know if there is one). Navigation and interaction in SPA is often application specific, MemLab doesn't know when and how to take heap snapshots without the puppeteer page object. Curious to hear if there is any ideas.