Bound function names no longer showing in snapshots
alistaircolling opened this issue · comments
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 :)
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
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).
Jest issue then not enzyme-to-json.