Expect.closeTo method | bun:test module | Bun
BuildDocsReferenceGuidesBlogDiscord/
bun:test/
Expect/
closeToMcloseTo
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
bun:test/
Expect/
closeToMcloseTo
method
test.Expect.closeTocloseTo(num: number,numDigits?: number): any;
Useful when comparing floating point numbers in object properties or array item. If you need to compare a number, use .toBeCloseTo instead.
The optional numDigits argument limits the number of digits to check after the decimal point. For the default value 2, the test criterion is Math.abs(expected - received) (that is, 10 ** -2 / 2).
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →