unsplash / sum-types

Safe, ergonomic, non-generic sum types in TypeScript.
https://unsplash.github.io/sum-types/
MIT License
42 stars 2 forks source link

Better Jest diffs for nullary sums #51

Open samhh opened 1 year ago

samhh commented 1 year ago

Following #50 sums should be comparable with toEqual, however when an expectation fails the diff is a bit rubbish for nullary sums, stating "serializes to the same string".

I believe this is caused by the value (also) being a function rather than just an object.

We could define a custom matcher to fix this, or even override toEqual. How can we differentiate between a nullary sum and a non-nullary constructor? Do we need to?

OliverJAsh commented 1 year ago

Here's one idea to solve this.