Enzyme: calling setProps causes "this.updater.enqueueCallback is not a function"

Created on 29 Sep 2017  路  7Comments  路  Source: enzymejs/enzyme

Enzyme version: 3.0.0
React version: 16.0.0

Test

import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });

test('Drop updates', () => {
  const onClose = jest.fn();
  const component = mount(<FakeInput onClose={onClose} />);
  component.setProps({ onClose: undefined });
  expect(component.getDOMNode()).toMatchSnapshot();
});

Error

TypeError: this.updater.enqueueCallback is not a function

      at WrapperComponent.Object.<anonymous>.ReactComponent.setState (node_modules/enzyme-adapter-utils/node_modules/react/lib/ReactBaseClasses.js:64:18)
      at WrapperComponent.setChildProps (node_modules/enzyme-adapter-utils/build/createMountWrapper.js:72:16)
      at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:217:26)
      at ReactWrapper.setProps (node_modules/enzyme/build/ReactWrapper.js:418:24)
      at Object.<anonymous> (src/js/components/Drop/__tests__/Drop-test.js:114:13)
      at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
      at process._tickCallback (internal/process/next_tick.js:109:7)

Any ideas what could be causing this?

Need To Reproduce v3 bugs

All 7 comments

FYI, by investigating this further I noticed that node_modules/enzyme-adapter-utils has a react 15 version inside node_modules/enzyme-adapter-utils/node_modules.

As a test, I manually deleted that React folder and the issue goes away.

I tried to analyze the package.json for enzyme-adapter-utils and I could not find anything wrong (it correctly uses a peer dependency). So I have no idea why it still has a react 15 copy. 馃槩

super weird. This problem seems to be with Yarn and the way they are handling peerDependencies.

If I use npm install it does not get the extra copy of React. I'm closing down this issue since I believe there is nothing to be fixed in your end.

If you file an issue on yarn, please link it here for posterity - thanks!

Upgrading from yarn v1.1.0 to v1.2.1 fixed issue for me 馃憤

I had the same issue while upgrading an app from react 15 to 16.
Upgrading yarn (to the latest version which is now 1.3.2) did do the trick :(

I had to manually override the transitive dependency in package.json like this

  "resolutions": {
    "enzyme-adapter-utils/react": "~16"
  },

Hopefully this will help others :)

@javierfernandes that doesn't sound like the right solution. You might not have the right dependency versions set up; overriding dependencies should never be required.

Was this page helpful?
0 / 5 - 0 ratings