We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 842cb98 commit 988f976Copy full SHA for 988f976
1 file changed
scripts/jest/matchers/toWarnDev.js
@@ -19,8 +19,10 @@ const createMatcherFor = consoleMethod =>
19
20
const unexpectedWarnings = [];
21
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.
+ // Catch errors thrown by the callback,
+ // But only rethrow them if all test expectations have been satisfied.
24
+ // Otherwise an Error in the callback can mask a failed expectations
25
+ // (and result in a test that passes when it shouldn't)
26
let caughtError;
27
28
const consoleSpy = message => {
@@ -87,6 +89,7 @@ const createMatcherFor = consoleMethod =>
87
89
};
88
90
}
91
92
+ // Any unexpected Errors thrown by the callback should fail the test.
93
if (caughtError) {
94
throw caughtError;
95
0 commit comments