-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expect(floatNumber).toBeNear(number, epsilon) #58
Comments
Thank you for this, at what times would you use either this or Jasmine's toBeCloseTo please? |
The second parameter of Jasmine's
|
Thanks @Nolanus, do I understand correctly that expect(22).toBeNear(20, 2); is equivalent to expect(22).toBeWithinRange(18, 22); |
Hi @JamieMason, Just realized my initial example was wrong, just fixed that. |
#68 adds the |
Compare a given value numerically to be in the range of
number-epsilon
andnumber+epsilon
. Thusepsilon
specifies the maximum tolerance the compared value is allowed to vary.Example
Implementation
Could internally use the "toBeWithinRange" matcher, but the above is much nicer to write if you're not targeting a specific range, but just a value and allow some wobbling.
The text was updated successfully, but these errors were encountered: