When I have
expect(result.toJSON())
.toEqual(<button className="btn btn-prev" onClick="{[Function onClick]}" type="button">Prev</button>);
it is close but not quite right - just missing the Function onClick
:
expect(received).toEqual(expected) // deep equality
- Expected
+ Received
<button
className="btn btn-prev"
- onClick="{[]}"
+ onClick={[Function onClick]} // <--- the difference, Function onClick is missing
type="button"
>
Prev
</button>
However if I try and add in the missing "Function onClick
", i.e.
expect(result.toJSON())
.toEqual(<button className="btn btn-prev" onClick="{[Function onClick]}" type="button">Prev</button>);
I get
- onClick="{[Function onClick]}"
+ onClick={[Function onClick]}
and if I remove the quotes i get a parsing error at onClick !
What is the right way to deal with this issue which must be a problem for others