Skip to content

Commit 1a8c80e

Browse files
committed
Improved clarity of inline comments
1 parent 842cb98 commit 1a8c80e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

scripts/jest/matchers/toWarnDev.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ const createMatcherFor = consoleMethod =>
1919

2020
const unexpectedWarnings = [];
2121

22-
// In order to avoid possible false positives from failed validations,
23-
// Hang onto any thrown Errors and re-throw them only if all validations pass.
22+
// Catch errors thrown by the callback,
23+
// But only rethrow them if all test expectations have been satisfied.
24+
// Otherwise an Error in the callback can mask a failed expectation,
25+
// and result in a test that passes when it shouldn't.
2426
let caughtError;
2527

2628
const consoleSpy = message => {
@@ -87,6 +89,7 @@ const createMatcherFor = consoleMethod =>
8789
};
8890
}
8991

92+
// Any unexpected Errors thrown by the callback should fail the test.
9093
if (caughtError) {
9194
throw caughtError;
9295
}

0 commit comments

Comments
 (0)