Jest: React.memo with snapshot testing results in <UNDEFINED> when upgrading to React 16.12.0

Created on 21 Nov 2019  路  2Comments  路  Source: facebook/jest

馃悰 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:

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


Bug Report Needs Repro Needs Triage

Most helpful comment

Is there a scheduled release date for v25?

All 2 comments

The fix is on master and will be released with v25: https://github.com/facebook/jest/pull/9196

Is there a scheduled release date for v25?

Was this page helpful?
0 / 5 - 0 ratings