configure custom wrappingComponent and use shallow method cause RangeError: Maximum call stack size exceeded
See original GitHub issueJest setup file:
import React from 'react';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
function CustomWrapper({ children }) {
return <div>{children}</div>;
}
configure({
adapter: new Adapter(),
wrappingComponent: CustomWrapper,
});
Test case:
import React from 'react';
import { shallow } from 'enzyme';
function Button() {
return <button>My Button</button>;
}
it('should work', function () {
const el = shallow(<Button />); // throw RangeError: Maximum call stack size exceeded
expect(el).toMatchSnapshot();
});
I found it seems to be this line: ShallowWrapper.js#L355
- enzyme: 3.10.0
- enzyme-adapter-react-16: 1.15.1
- jest: 24.9.0
- react: 16.12.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
enzymejs/enzyme - Gitter
It crashing ONLY when im trying to use mount, when use shallow everything works fine. ... RangeError: Maximum call stack size exceeded at...
Read more >JavaScript RangeError: Maximum Call Stack Size Exceeded
The JavaScript RangeError: Maximum call stack size exceeded is an error that occurs when there are too many function calls, or if a...
Read more >RangeError: Maximum call stack size exceeded Reactjs?
This method in index.js will cause an infinite loop when you call this method on your onChange event at Question component ❌
Read more >Shallow Rendering API - Enzyme - GitHub Pages
As of Enzyme v3, the shallow API does call React lifecycle methods such as componentDidMount and componentDidUpdate . You can read more about...
Read more >Error RangeError: Maximum call stack size exceeded
4. User changes date using "Calendar" control in top left corner of the scheduler. This is the calendar control that comes by default...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
I found a way to avoid this issue:
The makeShallowOptions function will merge
configure
options andshallow
passedOptions.Either way:This error is raised whenever
wrappingComponent
exists.Sorry, I actually execute the code only
configure
wrappingComponent
at the adapter level will raise this error, pass it inshallow
was ok.Test case: