-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🏗🐛 Print uncaught errors seen during tests (instead of rethrowing them) #17213
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approval for code; let others discuss the policy change itself
@@ -227,9 +227,6 @@ module.exports = { | |||
// Longer timeout on Travis; fail quickly at local. | |||
timeout: process.env.TRAVIS ? 10000 : 2000, | |||
}, | |||
// TODO(rsimha, #14406): Remove this after all tests are fixed. | |||
failOnConsoleError: !process.env.TRAVIS && !process.env.LOCAL_PR_CHECK, | |||
// TODO(rsimha, #14432): Set to false after all tests are fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO is about the next line, I assume. Are you removing it on purpose as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. We want to continue capturing console errors.
originalConsoleError(errorMessage + separator + helpMessage); | ||
} | ||
' \'expectAsyncConsoleError(<string or regex>[, <number of' + | ||
' times the error message repeats>]);'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add one instance to the PR where such an async error is correctly "expected" by a test.
Codecov Report
@@ Coverage Diff @@
## master #17213 +/- ##
==========================================
+ Coverage 77.78% 77.87% +0.09%
==========================================
Files 562 562
Lines 41164 41164
==========================================
+ Hits 32018 32057 +39
+ Misses 9146 9107 -39
Continue to review full report at Codecov.
|
@cramforce Done. Added an example to the PR description. |
Agree that we should avoid throwing on error messages, which might hit the Mocha bug. Is there a way to fail travis at the end if we see unexpected console errors? |
We've fought a long battle against uncaught errors in tests (starting with #7381). The solution put in place a while ago (#14336) involved allowing tests to declare errors that are expected during execution, and surfacing ones that weren't declared. Until now, the way we did so was to rethrow the errors (synchronously) so that the test would fail.
However, due to the large number of asynchronous code paths in the AMP runtime, It's not guaranteed that uncaught errors are thrown during the test body. Sometimes, they appear in between tests, which works badly with mocha (#15658), and causes subsequent tests to be silently skipped. While this doesn't happen during full Travis runs, it does happen during local development, and has proven to be very annoying. For example, see #16916 (review) and #17209 (review).
Given this context, this PR does the following:
In effect, this PR is backing off from the original policy laid out by @cramforce in #7381 (comment) (to fail tests that generate uncaught errors) due to the high cost of dealing with the resulting failures. However, the mechanism to detect these errors is still in place, and the hope is that printing them out during local development provides sufficient incentive to fix them.
Here's an example of a test that generates an unexpected async error:
Error message printed by the test:
The same test, but it now expects the error:
Fixes #15658
Addresses #16916 (review) and #17209 (review)
Closes #14406
Partially fixes #14360