Skip to content

Commit

Permalink
docs(expect): clarify the tolerance in toBeCloseTo (#6292)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandv authored Dec 23, 2024
1 parent 59ebe80 commit c65c048
Showing 1 changed file with 6 additions and 2 deletions.
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 certain margin of error
* (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

0 comments on commit c65c048

Please sign in to comment.