jest-matcher-deep-close-to icon indicating copy to clipboard operation
jest-matcher-deep-close-to copied to clipboard

Be within x percent of?

Open thedamon opened this issue 6 years ago • 2 comments

I'm testing a lot of numbers that are the result of looped calculations and the further the go the more 'off' they will be, but still potentially acceptably.

I was thinking to test these a within percentage of sort of function would be great and since they're in objects I was happy to find your library. Wondered if you had any interest in extending it in that area..

I'm not sure of an equivalent name of a test to build off of though

thedamon avatar Dec 16 '18 20:12 thedamon

That has all the sense, especially taking in mind that the relative error is sometimes more interesting than the absolute one, what is your proposal for the api?

maasencioh avatar Dec 17 '18 15:12 maasencioh

I'm not sure! Trying to think of a term that is short but also distinguishes between absolute and relative approximation. Maybe is relatively close to(target, percecntageDeviation)... Been meaning to look for equivalent APIs in other testing libraries

thedamon avatar Dec 24 '18 16:12 thedamon