Skip to content

TypeError: Cannot read property 'render' of undefined enzyme-adapter-react-14 #1667

@wKich

Description

@wKich

Describe the bug
Using stateless arrow functional component lead to an error.

To Reproduce

  1. Execute code:
import Enzyme, { mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-14'

Enzyme.configure({ adapter: new Adapter() })

const Bar = () => <div>{'Hello'}</div>
class Foo extends React.Component {
  render() { return <Bar /> }
}
mount(<Foo />)
  1. See error:
TypeError: Cannot read property 'render' of undefined
  at typeToNodeType (node_modules/enzyme-adapter-react-14/build/ReactFourteenAdapter.js:49:31)
  at instanceToTree (node_modules/enzyme-adapter-react-14/build/ReactFourteenAdapter.js:85:17)
  at instanceToTree (node_modules/enzyme-adapter-react-14/build/ReactFourteenAdapter.js:91:17)
  at instanceToTree (node_modules/enzyme-adapter-react-14/build/ReactFourteenAdapter.js:91:17)
  at Object.getNode (node_modules/enzyme-adapter-react-14/build/ReactFourteenAdapter.js:149:33)
  at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:100:33)
  at mount (node_modules/enzyme/build/mount.js:19:10)
  at Context.it (test.js:10:5)

Expected behavior
Code should works without error.

Desktop (please complete the following information):

  • OS: OSX 10.13.4
  • Browser: jsdom
  • Version: 11.1.0

Additional context

  • enzyme: 3.3.0
  • enzyme-adapter-react-14: 1.0.5
  • react: 0.14.9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions