Skip to content
masterclass Buddy

Jest · Matcher

toBeCloseTo

toBeCloseTo checks whether two floating-point numbers are approximately equal. Use it when exact decimal equality could fail because of rounding.

Last updated

Syntax

expect(received).toBeCloseTo(number, numDigits?)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • expect
  • toBe
  • toEqual
  • expect.closeTo

Source: Using Matchers · Jest. Checked 2026-11-03.