react-redux-7.1.0 Provider undefined in tests
See original GitHub issueWhat is the current behavior?
I am trying to write some tests for our custom hooks that use redux. I soon realized that any import from react-redux
in tests only include the connect
function. Is this expected? Using Jest as a test runner and CRA to run them.
import { Provider } from "react-redux"
console.log(Provider) // undefined
...
What is the expected behavior?
Provider to be defined.
Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?
react/react-dom: 16.8.2
react-redux: 7.1.0
redux: 4.0.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error when trying to install react-redux dependency
It looks like you are using the latest npm version (v7). ... Incase you are facing this issue with a react-native dependency then...
Read more >Continuous integration for React applications using Jest and ...
This tutorial covers: Cloning and setting up a sample React and Redux app; Writing tests for the application; Configuring continuous integration ...
Read more >Hooks - React Redux
Hooks. React's new "hooks" APIs give function components the ability to use local component state, execute side effects, and more.
Read more >React v17.0 Release Candidate: No New Features
In React 17, the behavior for forwardRef and memo components is consistent with regular function and class components. Returning undefined from ...
Read more >Get rid of "Unresolved function/method/variable" warning in ...
... function/method/variable" warning in Jest test files Follow ... get 'can not install Noe.js modul: Please specify npm or yarn package'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found the reason for the error.
I mocked this library and this led to the fact that I could not use the Provider in tests
Hah, nice 😃 For the record we would really recommend against trying to mock the
react-redux
lib or any of its APIs. Instead, we recommend actually creating real Redux stores in tests and rendering a<Provider store={store}>
around the component tree being tested:https://redux.js.org/usage/writing-tests#components