Skip to content
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

✅ Fail tests that call console error when they are run during local dev #15043

Merged
merged 2 commits into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build-system/pr-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ function main() {

// Run the local version of all tests.
if (!process.env.TRAVIS) {
process.env['LOCAL_PR_CHECK'] = true;
console.log(fileLogPrefix, 'Running all pr-check commands locally.');
runAllCommandsLocally();
stopTimer('pr-check.js', startTime);
Expand Down
2 changes: 2 additions & 0 deletions build-system/tasks/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ 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.
captureConsole: true,
},
Expand Down
16 changes: 12 additions & 4 deletions test/_init_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,12 @@ function warnForConsoleError() {
'test code that generated the error:\n' +
' \'allowConsoleError(() => { <code that generated the ' +
'error> });';
// TODO(rsimha, #14432): Throw an error here after all tests are fixed.
originalConsoleError(errorMessage + '\'\n' + helpMessage);
// TODO(rsimha, #14406): Simply throw here after all tests are fixed.
if (window.__karma__.config.failOnConsoleError) {
throw new Error(errorMessage + '\'\n' + helpMessage);
} else {
originalConsoleError(errorMessage + '\'\n' + helpMessage);
}
});
this.allowConsoleError = function(func) {
dontWarnForConsoleError();
Expand All @@ -301,8 +305,12 @@ function warnForConsoleError() {
const helpMessage =
'The test "' + testName + '" contains an "allowConsoleError" block ' +
'that didn\'t result in a call to console.error.';
// TODO(rsimha, #14432): Throw an error here after all tests are fixed.
originalConsoleError(helpMessage);
// TODO(rsimha, #14406): Simply throw here after all tests are fixed.
if (window.__karma__.config.failOnConsoleError) {
throw new Error(helpMessage);
} else {
originalConsoleError(helpMessage);
}
}
warnForConsoleError();
};
Expand Down