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

🏗 Flag an error and exit when Karma runs zero tests #34040

Merged
merged 5 commits into from
Apr 27, 2021
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
15 changes: 8 additions & 7 deletions build-system/tasks/runtime-test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
const argv = require('minimist')(process.argv.slice(2));
const fs = require('fs');
const path = require('path');
const {green, yellow, cyan} = require('kleur/colors');
const {green, yellow, cyan, red} = require('kleur/colors');
const {isCiBuild} = require('../../common/ci');
const {log, logWithoutTimestamp} = require('../../common/logging');
const {maybePrintCoverageMessage} = require('../helpers');
Expand Down Expand Up @@ -156,15 +156,16 @@ function maybePrintArgvMessages() {
async function karmaBrowserComplete_(browser) {
const result = browser.lastResult;
result.total = result.success + result.failed + result.skipped;
// Initially we were reporting an error with reportTestErrored() when zero tests were detected (see #16851),
// but since Karma sometimes returns a transient, recoverable state, we will
// print a warning without reporting an error to the github test status. (see #24957)
// This used to be a warning with karma-browserify. See #16851 and #24957.
// Now, with karma-esbuild, this is a fatal error. See #34040.
if (result.total == 0) {
rsimha marked this conversation as resolved.
Show resolved Hide resolved
log(
yellow('WARNING:'),
'Received a status with zero tests:',
cyan(JSON.stringify(result))
red('ERROR:'),
'Karma returned a result with zero tests.',
'This usually indicates a transformation error. See logs above.'
);
log(cyan(JSON.stringify(result)));
process.exit(1);
}
}

Expand Down
7 changes: 5 additions & 2 deletions build-system/test-configs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ const unitTestPaths = [
'extensions/**/test/unit/*.js',
];

// TODO(rsimha, #28838): Refine this opt-in mechanism.
const unitTestCrossBrowserPaths = ['test/unit/test-error.js'];
rsimha marked this conversation as resolved.
Show resolved Hide resolved
// TODO(amphtml): Opt-in more unit tests to run on Safari / FF / Edge.
const unitTestCrossBrowserPaths = [
'test/unit/core/test-error.js',
'test/unit/test-log.js',
];

const integrationTestPaths = [
'test/integration/**/*.js',
Expand Down