Skip to content

when mount-ing, context provided is not available to consumer  #1840

@elijahsmith

Description

@elijahsmith

Describe the bug
I have an HOC which consumes values from a Context and provides them to the wrapped component.

When I mount a component wrapped in this HOC, the context provided to the mount call (as part of the options second argument) is not available to the Consumer.

To Reproduce
You can see the failure in this codesandbox:

https://codesandbox.io/s/4wv1z3jl8w

When the context consumer executes, the context is undefined, even though I've provided a context (and childContextTypes!) in the second param to mount

Expected behavior
Context provided to the mount call should be available to the context consumers in the mounted component.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • macOS
  • chrome
  • Version 69.0.3497.92

Additional context
I found this behavior initially when trying to test a piece of a larger application but was able to reproduce is in the attached codesandbox.

I have found various references to how support for the "new" React context is barely complete; maybe I'm not using the correct combination of versions?

react: "16.4.2"
enzyme: "3.6.0"
enzyme-adapter-react-16: "1.5.0"

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