Jest snapshots change from v6 to v7
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
When generating shallow snapshots of react components with react-redux@6, if there is a connected component then its name looks like Connect(ComponentName)
. However, with react-redux@7, all connected component names look like Memo(ConnectFunction)
.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:
If you run the tests in this sandbox you’ll see that the ConnectedButton
component shows up as UNDEFINED
in the snapshot. This is not the same behavior I have locally but it is also not what I would expect. I cannot determine the reason for the different behavior, maybe some dependencies from react-scripts
are not up to date?
What is the expected behavior?
I would expect the component name to be something like: Memo(Connect(ComponentName))
.
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@16.8.6 react-dom@16.8.6 react-redux@7.0.2 redux@4.0.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (2 by maintainers)
Top GitHub Comments
As an alternative to the excellent suggestion by @ismay, you could also mock the
connect
function, like so:Only caveat is that the component does need to have a name.
from the looks of it, this should be fixed in jest v25 https://github.com/facebook/jest/issues/9216#issuecomment-556954371