Skip to content
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

docs(expect): clarify the tolerance in toBeCloseTo #6292

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions expect/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ export interface Expected<IsAsync = false> {
toBeCalledWith(...expected: unknown[]): void;

/**
* Asserts that the value is close to the specified number within a tolerance.
* Asserts that a given numerical value is approximately equal to an
* expected number within a within a certain margin of error
kt3k marked this conversation as resolved.
Show resolved Hide resolved
* (tolerance). Useful when comparing floating-point numbers, which
* may be represented internally with precision errors.
*
* @example Usage
* ```ts
Expand All @@ -189,7 +192,8 @@ export interface Expected<IsAsync = false> {
* ```
*
* @param candidate The candidate number.
* @param tolerance The tolerance value (optional).
* @param tolerance The number of significant decimal digits to
* consider when comparing the values (optional, default 2).
*/
toBeCloseTo(candidate: number, tolerance?: number): void;

Expand Down
Loading