[Testing] Upgrading to 1.1.0 and above causes tests to fail, Javascript heap out of memory
See original GitHub issueDescription
I upgraded react-md from 1.0.19 to 1.1.0 and ran into these issues, I just tried upgrading to 1.1.5 and still ran into the issues. I initialized the app using create-react-app and have never had any issues like this. It appears the issue is occurring in snapshot tests that I’m using enzyme to shallow render with the aid of enzyme-to-json. The issue isn’t with either of the testing methods, as I tried downgrading and the issues disappeared. I’ve dug around and found an issue where jest can experience memory leaks when running tests with the --coverage
flag but I’m experiencing the issue whether I run it with or without the flag.
I understand that this issue may be a problem with my app, and if that is the case I apologize for asking for help here. However, as the issue disappears when I downgrade back to 1.0.19 I believe it may be related to a change, though I can’t seem to pinpoint the source of the problem.
If anyone has any idea where the problem could be, I would greatly appreciate any pointers.
EDIT: I believe the issue is related to this issue in Jest.
EDIT 2: I’ve pinpointed the issue to snapshot tests for components that contain either the Menu
or SelectField
components. Could this issue be related to the recent ‘smart’ positioning menus?
Images/Screenshots
After downgrading, the tests pass again.
Version
- React - 15.6.1
- React-MD - 1.1.5, but issue first seen in 1.1.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (8 by maintainers)
It appears so. Setting the
fixedTo
prop in theMenu
to{}
allows the tests to work as expected. Ideally the bug I posted above will get fixed soon, but I can always update the default props forfixedTo
to betypeof window !== 'undefined' && (typeof global === 'undefined' || window !== global) ? window : {}
which would solve it for now.@Ardhimas @mlaursen Most probably this bug is caused in combination with
jest-environment-jsdom
. Because by defaultfixedTo
provides fullwindow
object, generating snapshot fails due to its size (component serialization to snapshot fails miserably).