generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly render
uncovered lines
column (#950)
* feat: improve code coverage percentage outputs and add yellow color * fix: use red for values lower than 75% * fix: not covered lines aren't json * refactor: share table printing function (dry) * test: coverage line formatting --------- Co-authored-by: Allan Oricil <[email protected]>
- Loading branch information
1 parent
339d6e5
commit cb48d08
Showing
5 changed files
with
359 additions
and
190 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2023, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { ensureArray } from '@salesforce/kit'; | ||
import { Ux } from '@salesforce/sf-plugins-core'; | ||
import { CodeCoverage } from '@salesforce/source-deploy-retrieve'; | ||
import chalk = require('chalk'); | ||
import { prepCoverageForDisplay } from '../coverageUtils'; | ||
|
||
/** | ||
* prints a table of formatted code coverage results if there are any | ||
* This is a no-op if tests didn't run or there is no coverage | ||
* | ||
* @param coverageFromMdapiResult | ||
* @param ux | ||
*/ | ||
export const maybePrintCodeCoverageTable = (coverageFromMdapiResult: CodeCoverage | CodeCoverage[], ux: Ux): void => { | ||
const codeCoverage = ensureArray(coverageFromMdapiResult); | ||
|
||
if (codeCoverage.length) { | ||
const coverage = prepCoverageForDisplay(codeCoverage); | ||
|
||
ux.log(''); | ||
ux.styledHeader(chalk.blue('Apex Code Coverage')); | ||
|
||
ux.table( | ||
coverage.map((entry) => ({ | ||
name: entry.name, | ||
numLocations: entry.numLocations, | ||
lineNotCovered: entry.lineNotCovered, | ||
})), | ||
{ | ||
name: { header: 'Name' }, | ||
numLocations: { header: '% Covered' }, | ||
lineNotCovered: { header: 'Uncovered Lines' }, | ||
} | ||
); | ||
} | ||
}; |
This file contains 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
This file contains 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
Oops, something went wrong.