Skip to content

dive() breaks when using the new context API. #1647

@stellarhoof

Description

@stellarhoof

Describe the bug

The new React context elements (https://reactjs.org/docs/context.html) report their type as objects instead of functions (custom react components) or strings (native react components), which breaks dive(). I haven't tested whether other methods of ShallowWrapper break.

To Reproduce

https://codesandbox.io/s/zxj4898zxp?module=%2Fsrc%2FApp.test.js

Expected behavior

shallow and dive should implement actual render semantics when handling the new context API:

  1. Automatically update current context whenever a context provider is encountered and remove the provider node from the tree.
  2. Automatically pass the current context to childs of context consumer nodes and remove the consumer node from the tree.

I'm sure the above are not the exact semantics, but at least the most intuitive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions