Skip to content

React.memo with snapshot testing results in <UNDEFINED> when upgrading to React 16.12.0 #9216

@danplubell

Description

@danplubell

🐛 Bug Report

After uplifting to React 16.12.0 all of my jest tests that do a shallow rendering and user snapshots started to fail because the name of the component is now rendered as if the component is a memo component.

An example is a component that with React 16.11 rendered in the snapshot like this:
<Memo(Connect(InjectIntl(OptimizerFooter))) />

After uplifting to v16.12 it renders like this:

These components are using React-Redux v7.1.1

To Reproduce

  • Create a component that uses React-Redux.connect
  • Create a test that does a shallow rendering of the component
  • Use toMatchSnapshot

Steps to reproduce the behavior:

Expected behavior

Ideally a Memo component would render as it did prior to React 16.12

Link to repl or repo (highly encouraged)

envinfo

System:
OS: macOS Mojave 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 8.9.2 - ~/.nvm/versions/node/v8.9.2/bin/node
npm: 6.12.1 - ~/.nvm/versions/node/v8.9.2/bin/npm
npmPackages:
jest: ^24.8.0 => 24.9.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions