Skip to content

Commit 49a3b76

Browse files
committed
refactor: remove manual try/catch because Jest covers this case
1 parent e04af18 commit 49a3b76

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

Sprint-3/2-practice-tdd/repeat-str.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ function repeatStr(str, count) {
2727
module.exports = repeatStr;
2828

2929

30-
// Case: Manual inspection of the Error object
31-
// We use try/catch to log the error message to the console
32-
// to verify it's working as expected without breaking the test suite.
33-
test("Should log the specific error message to the console", () => {
34-
try {
35-
repeatStr("hi", -3);
36-
} catch (error) {
37-
console.log("Verified Error Message ->", error.message);
38-
39-
// Check if the message is exactly what we defined
40-
expect(error.message).toBe("count cannot be negative");
41-
}
4230

43-
// Also verify that it actually throws using Jest's built-in matcher
44-
expect(() => repeatStr("hi", -3)).toThrow();
45-
});
31+
32+
33+
// // Case: Manual inspection of the Error object
34+
// // We use try/catch to log the error message to the console
35+
// // to verify it's working as expected without breaking the test suite.
36+
// test("Should log the specific error message to the console", () => {
37+
// try {
38+
// repeatStr("hi", -3);
39+
// } catch (error) {
40+
// console.log("Verified Error Message ->", error.message);
41+
42+
// // Check if the message is exactly what we defined
43+
// expect(error.message).toBe("count cannot be negative");
44+
// }
45+
46+
// });

0 commit comments

Comments
 (0)