We use a lot of floating point numbers and they are not correctly compared by default matchers.
It is preferred to not go too deep into the app-specific data structures ant to not hard-code object layouts etc., if possible.
It is desirable to parameterize the "closeness" of the compared values, either on absolute difference (commonly called "epsilon") or on Units in the Last Place (ULPs) in its IEEE-754 representation.
🔦 Context
We want to avoud hardcoding expectations and comparing them with .toBeClose()because it is very tedious to fix all the tests after every small change in the algorithm.
We want to update snapshots with jest -u instead. However, this require a snapshot matcher that understands floating point numbers.
🙋 Feature Request
Introduce a set of custom Jest snapshot matchers that could work for our assertions better. https://jestjs.io/docs/en/expect#custom-snapshot-matchers https://github.com/maasencioh/jest-matcher-deep-close-to
We use a lot of floating point numbers and they are not correctly compared by default matchers.
It is preferred to not go too deep into the app-specific data structures ant to not hard-code object layouts etc., if possible.
It is desirable to parameterize the "closeness" of the compared values, either on absolute difference (commonly called "epsilon") or on Units in the Last Place (ULPs) in its IEEE-754 representation.
🔦 Context
We want to avoud hardcoding expectations and comparing them with
.toBeClose()
because it is very tedious to fix all the tests after every small change in the algorithm. We want to update snapshots withjest -u
instead. However, this require a snapshot matcher that understands floating point numbers.😯 Describe the feature
💻 Examples
💁 Possible Solution
Related