Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full example with connected Component #33

Closed
cristiam86 opened this issue Sep 27, 2019 · 3 comments
Closed

Full example with connected Component #33

cristiam86 opened this issue Sep 27, 2019 · 3 comments

Comments

@cristiam86
Copy link

Describe the bug
Following the guides from the documentation about the enzyme-context-redux plugin (here) I miss an examle of the component to be tested. In my project I want to test a connected component but always get the following error when try to shallow it:
Invariant Violation: Could not find "store" in the context of "Connect(ReduxExampleHeader)". Either wrap the root component in a , or pass a custom React context provider to and the corresponding React context consumer to Connect(ReduxExampleHeader) in connect options.

To Reproduce
Steps to reproduce the behavior:

  1. Follow the steps on the documentation
  2. Try to sallow your component: shallow(<ReduxExampleHeader />)
  3. See error

Expected behavior
The component should be rendered

System information
OS Version: Windows 10 pro,
Node Version: v10.15.3
Enzyme Version: 3.10.0
React Version:16.9.0
React Redux: 7.1.1
Redux: 4.0.4

@minznerjosh
Copy link
Contributor

Unfortunately this is because the latest version of react-redux uses the useContext hook under the hood. useContext is currently not supported by enzyme shallow, largely due to limitations with the react shallow renderer.

Downgrading to react-redux@v5.x would allow use of shallow again. Alternatively, you could switch to mount which does support useContext.

Here's the relevant enzyme issue: enzymejs/enzyme#2176

@cristiam86
Copy link
Author

Thanks @minznerjosh I'll let you know if I can make it work.

@naudo
Copy link

naudo commented Jun 19, 2024

We are moving to archive this repo as we no longer support it and am closing this issue as "won't fix".

If you're interested in maintaining this repo, please reach out!

@naudo naudo closed this as completed Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants