Skip to content

Using <React.Fragment> prints warning with enzyme's mount with IE11 #1503

@sylvain-hamel

Description

@sylvain-hamel

I have a component that returns a <React.Fragment> object. When I mount the component using enzyme, in Internet Explorer 11, then React prints out this warning:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

Followed by this warning:

Warning: Each child in an array or iterator should have a unique "key" prop. See https://fb.me/react-warning-keys for more information

About the 2nd warning, I'm pretty sure it's confusing the Fragment "array" with a common JSX array and it's trying to validate that each of the Fragment "element" has a key.

More info:

  • The same test runs without any warning on Chrome, Edge and Firefox.
  • This does not happen when I load the application on screen in Internet Explorer 11. It only happens in my unit tests; this is why I think it's related to enzyme.

Current behavior

Some warnings are printed

Expected behavior

No warnings should be printed

Your environment

Windows, Internet Explorer, Karma, Jasmine

API

  • shallow
  • mount
  • render

Version

library version
Enzyme 3.2.0
React 16.2.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )

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