Skip to content

Writing tests with multiple slots as children-object fail #3

Description

@dazlious

I just ran into a problem writing tests for your "Containment with multiple slots using children".

Invariant Violation: Objects are not valid as a React child (found: object with keys {header}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons.

When I shallow my component using enzyme, all is fine. If I use component.find() this error happens.

      at invariant (node_modules/fbjs/lib/invariant.js:44:15)
      at traverseAllChildrenImpl (node_modules/react/lib/traverseAllChildren.js:144:56)
      at traverseAllChildren (node_modules/react/lib/traverseAllChildren.js:172:10)
      at Object.forEachChildren [as forEach] (node_modules/react/lib/ReactChildren.js:71:3)
      at childrenOfNode (node_modules/enzyme/build/ShallowTraversal.js:45:31)
      at treeForEach (node_modules/enzyme/build/ShallowTraversal.js:63:3)
      at node_modules/enzyme/build/ShallowTraversal.js:64:12
      at Array.forEach (native)
      at treeForEach (node_modules/enzyme/build/ShallowTraversal.js:63:24)
      at node_modules/enzyme/build/ShallowTraversal.js:64:12
      at Array.forEach (native)
      at treeForEach (node_modules/enzyme/build/ShallowTraversal.js:63:24)
      at node_modules/enzyme/build/ShallowTraversal.js:64:12
      at Array.forEach (native)
      at treeForEach (node_modules/enzyme/build/ShallowTraversal.js:63:24)
      at node_modules/enzyme/build/ShallowTraversal.js:64:12
      at Array.forEach (native)
      at treeForEach (node_modules/enzyme/build/ShallowTraversal.js:63:24)
      at node_modules/enzyme/build/ShallowTraversal.js:64:12
      at Array.forEach (native)
      at treeForEach (node_modules/enzyme/build/ShallowTraversal.js:63:24)
      at treeFilter (node_modules/enzyme/build/ShallowTraversal.js:70:3)
      at ShallowWrapper.<anonymous> (node_modules/enzyme/build/ShallowWrapper.js:56:12)
      at node_modules/enzyme/build/ShallowWrapper.js:1323:21
      at Array.map (native)
      at ShallowWrapper.flatMap (node_modules/enzyme/build/ShallowWrapper.js:1322:37)
      at ComplexSelector.findWhereUnwrapped (node_modules/enzyme/build/ShallowWrapper.js:55:18)
      at ComplexSelector.find (node_modules/enzyme/build/ComplexSelector.js:133:21)
      at ShallowWrapper.find (node_modules/enzyme/build/ShallowWrapper.js:594:37)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions