-
Notifications
You must be signed in to change notification settings - Fork 273
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
Out of memory error using debug() in an Animated.FlatList with a ref #539
Comments
Hi, we've faced a similar issue. As an example, you can run: import React, { useRef } from 'react';
import { Animated } from 'react-native';
import { render } from 'react-native-testing-library';
const Component = () => {
const ref = useRef(null);
return <Animated.View ref={ref} />;
};
describe('component', () => {
it('renders', () => {
const page = render(<Component />);
expect(page).toMatchSnapshot();
});
}); And see that the snaphsot is nearly 3,000 lines long. Also this might be linked to jestjs/jest#8109 |
Any update on that? |
### Description This fixes the regression described in #6314. The change in #6230 made the underlying problem in `AlertBanner` more prominent as it caused the top level navigator to re-render on app state change (background/foreground/inactive) and hence the `AlertBanner`. ### Other changes Globally mock `Animated.View` and `Animated.ScrollView` to prevent out of memory error when a ref is set. See callstack/react-native-testing-library#539 Note: This change caused the Snapshot updates, because the styles are not flattened anymore for the mocked `Animated.View`. ### Tested - Last alert is not redisplayed when navigating to different screens. - New alert banner with same content can still be redisplayed when dispatched (causing a state change). ### Related issues - Fixes #6314 ### Backwards compatibility Yes
What I did was increase the size of memory for node |
Just encountered this too in the form of jestjs/jest#8109 Sad, that there does not seem to be a workaround for that. Increasing the memory of the node process is not really a valid solution. The ref problem has its roots somewhere else. edit: Seems my problem goes away when I am using |
adding this worked for my test: import { Animated, View } from 'react-native';
...
it('should work', () => {
Object.defineProperty(Animated, 'View', {
get value() {
return View;
},
});
...
}); |
On the lines of @pke comments, re-adjusting the |
Depending on the Node version you're using, the OOM might be compounded by this issue: jestjs/jest#11956 |
Seems like the root issue is related to the actual size of component tree generated by using
|
How did you mock |
Something like that should work
|
Describe the bug
I'm implementing a test in a component that renders an
Animated.FlatList
, when I use debug the test hangs and eventually throws a JavaScript heap out of memory error.I found out that If I remove the ref I'm passing to the
Animated.FlatList
everything works fine.It also works with a regular
FlatList
.Expected behavior
Test shouldn't hang and debug() output should be visible in the console.
Steps to Reproduce
Run this test:
The test will hang and throw this error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Versions
The text was updated successfully, but these errors were encountered: