enzymejs/enzyme

configure custom wrappingComponent and use shallow method cause RangeError: Maximum call stack size exceeded

Open

#2309 opened on Dec 25, 2019

View on GitHub
 (5 comments) (0 reactions) (0 assignees)JavaScript (19,979 stars) (2,016 forks)batch import
API: shallowbughelp wanted

Description

Jest 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

Contributor guide