Skip to content

Commit

Permalink
docs(expect): clarify the tolerance in toBeCloseTo
Browse files Browse the repository at this point in the history
  • Loading branch information
dandv authored Dec 22, 2024
1 parent d625a03 commit 2c5dd0d
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 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 2c5dd0d

Please sign in to comment.