Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(expect): check error message of .toBeCloseTo() #6296

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions expect/_to_be_close_to_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,21 @@ Deno.test("expect().toBeCloseTo() throws custom message", () => {
new RegExp(`^${msg}`),
);
});

Deno.test("expect().toBeCloseTo() throws error messages which include expected and actual values", () => {
assertThrows(
() => {
expect(0.2 + 0.11).toBeCloseTo(0.3);
},
AssertionError,
`Expected the value 0.31 to be close to 0.3 (using 2 digits), but it is not`,
);

assertThrows(
() => {
expect(0.2 + 0.1).not.toBeCloseTo(0.3);
},
AssertionError,
`Expected the value 0.30000000000000004 not to be close to 0.3 (using 2 digits), but it is`,
);
});
Loading