feat(tester): agent-friendly bit test output with per-component rollup#10313
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks bit test output to provide an agent-/human-friendly rollup of results across components and environments, including a concise final summary and an additive JSON summary block.
Changes:
- Skip invoking testers when an env has zero spec files (reduces “0 passing (0ms)” noise).
- Add a new
test-output-formattermodule to aggregate results and render a per-component rollup + final summary (with--verboseexpanding the “no tests” list). - Extend
bit test --jsonoutput with an additionalsummaryobject (totals + per-component counts + env errors).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
scopes/defender/tester/tester.service.ts |
Filters out components with zero spec files before running the tester; returns empty results when none have tests. |
scopes/defender/tester/test.cmd.ts |
Adds --verbose, uses the new aggregator/formatter for human output, and adds summary to JSON output. |
scopes/defender/tester/test-output-formatter.ts |
New aggregation + rendering logic for per-component rollup, env errors, no-tests section, and final headline. |
scopes/defender/tester/test-output-formatter.spec.ts |
Unit tests covering aggregation and report rendering. |
… alongside tester errors
GiladShoham
approved these changes
Apr 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
scopes/defender/tester/tester.service.ts:156
specFilesis filtered down to components with spec files, butpatterns(andtesterContext.componentsviaObject.assign(context, ...)) still include allcontext.components. Testers like the built-in Jest tester derive the executed spec patterns fromcontext.patterns(scopes/defender/jest/jest.tester.ts:303-308), so components with zero spec files will still be passed to the tester, undermining the “skip empty-component invocations” goal and potentially reintroducing noise/extra work. Consider filteringpatterns(and overridingtesterContext.components) to match the filteredspecFiles.componentsset so empty components are truly excluded from the tester run.
const allSpecFiles = ComponentMap.as(context.components, (component) => {
return detectTestFiles(component, this.devFiles);
});
// drop components with zero spec files before handing them to the tester — otherwise testers
// like Mocha invoke their reporter once per component and print "0 passing (0ms)" noise.
const specFiles = allSpecFiles.filter((files) => files.length > 0);
const componentWithTests = specFiles.toArray().length;
if (componentWithTests === 0 && !options.ui) {
// silent: the final summary in `bit test` collapses no-test components into a single line.
return new Tests([]);
}
if (!options.ui)
this.logger.console(`testing ${componentWithTests} components with environment ${chalk.cyan(context.id)}\n`);
const patterns = await ComponentMap.asAsync(context.components, async (component) => {
const componentDir = this.workspace.componentDir(component.id);
const componentPatterns = this.devFiles.getDevPatterns(component, TesterAspect.id);
const packageRootDir = await this.workspace.getComponentPackagePath(component);
return {
componentDir,
packageRootDir,
paths:
componentPatterns.map((pattern: string) => ({
path: resolve(componentDir, pattern),
relative: pattern,
})) || [],
};
});
let additionalHostDependencies = [];
if (
context.env.getAdditionalTestHostDependencies &&
typeof context.env.getAdditionalTestHostDependencies === 'function'
) {
additionalHostDependencies = await context.env.getAdditionalTestHostDependencies();
}
const testerContext = Object.assign(context, {
release: false,
specFiles,
patterns,
sourcePatterns: patterns,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rework
bit testoutput so humans and AI agents can tell pass/fail at a glance:›bullet for pass,✖for fail,⚠for tester error), following the shared CLI style guide.✔ 359/359 tests passed across 17 components, 79 without tests).--verboseexpands to the full list).TesterService, removing Mocha's0 passing (0ms)noise.--summaryflag: suppress tester output, print only the final headline. With--json,databecomes a structured summary (totals, per-component rollup, components-without-tests, env errors) — ideal for agents that just need to grep pass/fail.no tests found for components using environment Xwarning — the new summary covers it.Uses the shared
@teambit/clioutput toolkit. Unit tests cover aggregation and rendering.