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

Bound function names no longer showing in snapshots #103

Closed
alistaircolling opened this issue Apr 19, 2018 · 3 comments
Closed

Bound function names no longer showing in snapshots #103

alistaircolling opened this issue Apr 19, 2018 · 3 comments

Comments

@alistaircolling
Copy link

alistaircolling commented Apr 19, 2018

Hi there, I recently upgraded a project:

From

  • React 15.4.2
  • Enzyme 2.8.2
  • enzyme-to-json 1.5.1

To

  • React 16.3.1
  • Enzyme 3.3.0
  • enzyme-to-json 3.3.3

Now lots of tests are failing due to snapshots not matching:

  + expected - actual
      -    onBlur={[Function]}
      -    onChange={[Function]}
      +    onBlur={[Function bound onBlurHandler]}
      +    onChange={[Function bound onChangeHandler]}

Is this expected behaviour? I guess tests are more brittle if the handler names are there.
Thanks :)

@rosath
Copy link

rosath commented Jun 5, 2018

I have the same issue with shallow render:

  • React 16.4.0
  • Enzyme 3.3.0
  • enzyme-to-json 3.3.4
  • Jest 20.0.4

@michelts
Copy link

michelts commented Aug 3, 2019

Jest stopped to show function names in snapshots. This comment from another discussion expose why.

There is a work in progress to offer an alternative, but it is not done yet.

In your specific case, I would recommend to test the handlers explicitly (e.g. get a wrapper and simulate blur and change).

@VincentLanglet
Copy link
Collaborator

Jest issue then not enzyme-to-json.

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

No branches or pull requests

4 participants