Skip to content

Commit c65c048

Browse files
authored
docs(expect): clarify the tolerance in toBeCloseTo (#6292)
1 parent 59ebe80 commit c65c048

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

expect/_types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ export interface Expected<IsAsync = false> {
177177
toBeCalledWith(...expected: unknown[]): void;
178178

179179
/**
180-
* Asserts that the value is close to the specified number within a tolerance.
180+
* Asserts that a given numerical value is approximately equal to an
181+
* expected number within a certain margin of error
182+
* (tolerance). Useful when comparing floating-point numbers, which
183+
* may be represented internally with precision errors.
181184
*
182185
* @example Usage
183186
* ```ts
@@ -189,7 +192,8 @@ export interface Expected<IsAsync = false> {
189192
* ```
190193
*
191194
* @param candidate The candidate number.
192-
* @param tolerance The tolerance value (optional).
195+
* @param tolerance The number of significant decimal digits to
196+
* consider when comparing the values (optional, default 2).
193197
*/
194198
toBeCloseTo(candidate: number, tolerance?: number): void;
195199

0 commit comments

Comments
 (0)