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

Shallow.debug() does not output a React.memo(React.forwardRef) SFC properly #2181

Closed
2 of 13 tasks
Dilatorily opened this issue Jul 1, 2019 · 3 comments
Closed
2 of 13 tasks

Comments

@Dilatorily
Copy link

Current behavior

The .debug() method of a shallow() component that is wrapped in both memo and forwardRef, will return a Memo([Object object]) component.

This repository reproduces the issue.

Results

 enzyme
    ✓ debugs correctly with a shallow memo'ed SFC (7ms)
    ✓ debugs correctly with a shallow forwarded ref SFC (1ms)
    ✕ debugs correctly with a shallow memo'ed forwarded ref SFC (3ms)

  ● enzyme › debugs correctly with a shallow memo'ed forwarded ref SFC

    expect(received).toMatchInlineSnapshot(snapshot)

    Snapshot name: `enzyme debugs correctly with a shallow memo'ed forwarded ref SFC 1`

    - Snapshot
    + Received

      "<div>
    -   <Memo(ForwardRef) />
    +   <Memo([object Object]) />
      </div>"

      51 |     };
      52 |     expect(shallow(<Container />).debug())
    > 53 |       .toMatchInlineSnapshot(
         |        ^
      54 |     `
      55 |       "<div>
      56 |         <Memo(ForwardRef) />

      at Object.toMatchInlineSnapshot (index.spec.jsx:53:8)

 › 1 snapshot failed.

Expected behavior

The debug() method returns Memo(ForwardRef).

Your environment

API

  • shallow
  • mount
  • render

Version

library version
enzyme 3.10.0
react 16.8.6
react-dom 16.8.6
react-test-renderer 16.8.6
adapter (below) 1.14.0

Adapter

  • enzyme-adapter-react-16
  • enzyme-adapter-react-16.3
  • enzyme-adapter-react-16.2
  • enzyme-adapter-react-16.1
  • enzyme-adapter-react-15
  • enzyme-adapter-react-15.4
  • enzyme-adapter-react-14
  • enzyme-adapter-react-13
  • enzyme-adapter-react-helper
  • others ( )
@Izkata
Copy link

Izkata commented Feb 19, 2021

I'm also seeing the same thing without the extra "memo" wrapper, getting debug output like <[Object object] />. It appears to just be from forwardRef.

@ljharb
Copy link
Member

ljharb commented Feb 19, 2021

This appears to be fixed, presumably by ddb0627 (which fixed #2146). When I update your repro repo to the latest enzyme and react adapter, everything passes.

@ljharb ljharb closed this as completed Feb 19, 2021
@ljharb
Copy link
Member

ljharb commented Feb 19, 2021

@Izkata if you're still having trouble on the latest version of everything, please file a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants