adriantoine / enzyme-to-json

Snapshot test your Enzyme wrappers
MIT License
947 stars 64 forks source link

Bound function names no longer showing in snapshots #103

Closed alistaircolling closed 5 years ago

alistaircolling commented 6 years ago

Hi there, I recently upgraded a project:

From

To

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 commented 6 years ago

I have the same issue with shallow render:

michelts commented 5 years ago

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 commented 5 years ago

Jest issue then not enzyme-to-json.