-
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
🏗 Surface console errors during tests as mocha failures #14336
Conversation
/to @cramforce @erwinmombay @choumx I'm still working on this, but figured I'd send it out for review in the meantime. The main change to review is at test/_init_tests.js. The rest of the changes either fix broken tests, or skip ones that were masking console errors and silently passing before this PR. |
Is there a pattern to "expect" an error, so that it doesn't fail the test? |
@cramforce Yes, there is. I've updated the PR description. |
How do others feel about skipping so many tests. I suppose it is good to get this in. Maybe we can do a one time follow up to add expectations where it makes sense. |
Yeah, I thought about it last week as I skipped test after test (...after test). The alternative (surfacing errors as test failures and fixing all tests in one PR) seemed too onerous and error prone to attempt. FWIW, we're skipping ~200 out of ~6000 unit tests, and ~10 out of ~400 integration tests. Once I get this PR to pass Travis, I'll add all the folks whose tests are being skipped as reviewers for comment and see what they think. |
Tangent: Code coverage dashboard could be a carrot for fixing flaky extension tests.. and adding visual diff tests. 😄 |
@cramforce @choumx @erwinmombay Travis is green! This PR is now ready for a full review. All the tests that are being skipped in this PR were silently passing in spite of one or more console errors being thrown by the AMP runtime. I've assigned TODOs to whoever substantially edited the skipped tests most recently. Instructions for fixing these tests are in the PR description. In most cases, a skipped test (or a set of skipped tests) can be fixed with a small change to either the runtime code, or by wrapping a function call in a test within an ccing a few people for visibility and comment: @dvoytenko, @aghassemi, @lannka, @zhouyx, @cvializ, @alanorozco, @bradfrizzell |
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.
I feel the skips are too coarse grained. Could we instead add expectations for whatever error logs we need automatically for the failing tests?
submitButton.setAttribute('type', 'submit'); | ||
form.appendChild(submitButton); | ||
// TODO(aghassemi, #14336): Fails due to console errors. | ||
describe.skip('AmpForm Integration', () => { |
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.
I'm scared skipping this test.
@cramforce I wasn't able to make the skips any more fine-grained than they are, because for many tests / test suites, the errors were being thrown in Re: automatically expecting the errors, I did try and debug the first few tests that I skipped to see where I would need to insert the expectations for the errors, and quickly realized that in order to do so, I had to dig into the source code of each component being tested. At this rate, I wouldn't be able to fix all the failing AMP tests even if I spent the next month working on nothing but this PR. I'd imagine it will take the person who wrote each test a fraction of the time, given their knowledge of how their components work. Another thing I noticed while debugging is that a lot of the AMP tests are very flaky as they're currently written. I figured that this PR would work as a good incentive to fix our tests for good. One option is for me to leave this PR unmerged until each component owner has had a chance to cherry-pick the first commit in this PR (the one that adds the stub for Finally, here's a visual representation of how many unit tests we're actually skipping via this PR (about 6% of the total number of unit tests). For integration tests, we're only skipping tests in 5-6 files. WDYT? |
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.
I'm fine with shipping this. Please report back in 4 weeks how many of the tests did get unskipped.
I wonder if this will make our integration tests less flaky i.e. whether or not these tests were a major source of flakiness. Something to watch out for. |
@choumx I think our integration test flakiness arises from a combination of errors that were not being caught (now fixed), and asynchronous operations that are causing tests to timeout some of the time. Agree, it's worth keeping an eye on. |
The changes in this PR were replaced by the changes in #14336. Highlights:
|
Calls to
console.info
,console.log
,console.warn
, andconsole.error
are suppressed during AMP tests due to theclient.captureConsole: false
configuration value inkarma-conf.js
. If not for this, the test logs will become extremely noisy. However, suppressingconsole.error
in particular is a bad thing, since genuine runtime errors during tests can get masked.This PR does the following:
console.error
during tests and surfaces them as mocha test errors, causing the individual test that generated the error to fail with a useful message. Other tests will continue to be run like normal.instructions:
If a test you wrote was skipped by this PR, unskip it and see what the
console.error
is all about.expect
block around the test step that generates the error.Examples (UPDATED): See here.
Examples (OUTDATED):
This test will fail...
... and so will this test...
... but this test will pass...
Fixes #7381
Partially addresses #14360
Tracking issue for unskipping tests #14406