@patina/core
v2.1.0
Published
Type-safe nothing-handling and error-handling library
Downloads
471
Maintainers
Readme
Similar libraries
Other useful libraries
Testing
Adding an iterator to the Result class has introduced behavior that affects how testing libraries handle deep comparisons of instances of this class. This is interfering with how deep equality checks are performed, as the tests rely on iterating over object properties or their prototypes to determine equality.
This means asserting equality between any two instances of the Result class will always pass, even if the instances are not equal:
expect(Ok()).toEqual(Ok(1));
expect(Err()).toEqual(Err(1));
expect(Ok()).toEqual(Err());
To properly test equality between instances of the Result class, you can unwrap the value and compare it directly:
expect(Ok().unwrap()).toEqual(Ok(1).unwrap()); // Now fails as expected