Enzyme: After updating enzyme and adapter, all mount throw errors

Created on 6 Apr 2019  路  6Comments  路  Source: enzymejs/enzyme

Thanks for reporting an issue to us! We're glad you are using and invested in Enzyme.
Before submitting, please read over our commonly reported issues to prevent duplicates!

Current behavior

Run all my tests, with every test leveraging mount() failing with the following error:
TypeError: (0 , _enzymeAdapterUtils.getNodeFromRootFinder) is not a function

Expected behavior

Run all my tests without error.

Your environment

https://github.com/OperationCode/front-end
MacOS latest

API

  • [ ] shallow
  • [X] mount
  • [ ] render

Version

| library | version
| ------------------- | -------
| enzyme | 3.9.0
| react | 16.8.6
| react-dom | 16.8.6
| react-test-renderer | 16.8.6
| adapter (below) |

Adapter

  • [X] enzyme-adapter-react-16 Version 1.12.0
  • [ ] enzyme-adapter-react-16.3
  • [ ] enzyme-adapter-react-16.2
  • [ ] enzyme-adapter-react-16.1
  • [ ] enzyme-adapter-react-15
  • [ ] enzyme-adapter-react-15.4
  • [ ] enzyme-adapter-react-14
  • [ ] enzyme-adapter-react-13
  • [ ] enzyme-adapter-react-helper
  • [ ] others ( )
package 16

Most helpful comment

v1.12.1 of the adapter is published. Happy to reopen if that doesn't solve it.

All 6 comments

Just wanted to report the same error.

Minimal example

Component:

import * as React from 'react';

interface TestComponentProps {
}

export class TestComponent extends React.Component<TestComponentProps> {

    render() {
        return (
            <div className='TestComponent'>
                Test
            </div>
        );
    }
}

Tests:

import * as React from 'react';
import { configure, mount, shallow } from 'enzyme';
import * as ReactSixteenAdapter from 'enzyme-adapter-react-16';
import {TestComponent} from './TestComponent';

configure({ adapter: new ReactSixteenAdapter() });

describe('TestComponent', () => {

   // Working on both 1.11.2 and 1.12.0
   it('should contain a div with the correct class (shallow)', () => {
       const testComponent = shallow(<TestComponent />);

       expect(testComponent.find('.TestComponent')).toHaveLength(1);
      }
   );

   // Failing on 1.12.0. Working on 1.11.2
   it('should contain a div with the correct class (mount)', () => {
       const testComponent = mount(<TestComponent />);

       expect(testComponent.find('.TestComponent')).toHaveLength(1);
   });
});

Thanks, looks like I need to publish a patch that bumps the minimum version of adapter-utils. Coming shortly.

Specifically, you can fix this by ensuring enzyme-adapter-utils is fully updated - if you have a lockfile, that might be causing the problem - but by publishing a patch, it'll force it to be updated.

v1.12.1 of the adapter is published. Happy to reopen if that doesn't solve it.

Thanks for the fix. Works for me! 馃憤

Absurdly fast. Thanks @ljharb

Was this page helpful?
0 / 5 - 0 ratings