This action uses a text coverage report from Jest and generates a Markdown report based on it in the format shown below. The table shows the status of each file. Each file and uncovered line is properly linked to it's examined version on GitHub.
St | File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|---|
🟡 | All files | 70.58 | 72.22 | 83.33 | 71.42 | |
🟡 | src | 63.23 | 64.28 | 80 | 64.17 | |
🔴 | main.ts | 0 | 0 | 0 | 0 | 1-37 |
🟢 | report.ts | 95.55 | 100 | 88.88 | 95.55 | 14-15 |
🟢 | src/utils | 100 | 100 | 100 | 100 | |
🟢 | getReportParts.ts | 100 | 100 | 100 | 100 | |
🟢 | status.ts | 100 | 100 | 100 | 100 |
Note This package isn’t part of our core product. It’s kindly shared “as-is” without any guaranteed level of support from Fingerprint. We warmly welcome community contributions.
The action returns a markdownReport
output that you can use in other actions. The example below shows how to use the
report in a pull request comment.
steps:
- name: Prepare coverage report in markdown
uses: fingerprintjs/action-coverage-report-md@v2
id: coverage
- name: Add coverage comment to the PR
uses: marocchino/sticky-pull-request-comment@v2
with:
message: ${{ steps.coverage.outputs.markdownReport }}
steps:
- name: Prepare coverage report in markdown
uses: fingerprintjs/action-coverage-report-md@v2
id: coverage
with:
textReportPath: './coverage/text-report.txt'
srcBasePath: './utils'
- name: Add coverage comment to the PR
uses: marocchino/sticky-pull-request-comment@v2
with:
message: ${{ steps.coverage.outputs.markdownReport }}
You can add a code coverage report to the job summary. For more information, see Adding a job summary in the GitHub Actions documentation.
steps:
- name: Prepare coverage report in markdown
uses: fingerprintjs/action-coverage-report-md@v2
id: coverage
with:
textReportPath: './coverage/text-report.txt'
srcBasePath: './utils'
- name: Add coverage report to the job summary
run: |
echo "## Code Coverage" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.coverage.outputs.markdownReport }}" >> $GITHUB_STEP_SUMMARY
Name | Type | Default Value | Description |
---|---|---|---|
textReportPath |
string |
'./coverage/coverage.txt' |
Path to the coverage report in the Istanbul text format. |
srcBasePath |
string |
'./src' |
Base path for the source folder. |
Name | Type | Description |
---|---|---|
markdownReport |
string |
Coverage report in Markdown format. |
- Using a CLI:
npx jest --coverage --coverageReporters="text" > coverage.txt
- Using a Configuration file:
module.exports = {
// ... other settings
coverageReporters: [['text', { file: 'coverage.txt', path: './' }]],
};
- Using a CLI:
npx nyc report --reporter=text > ./coverage/coverage.txt
- Using a Configuration file:
module.exports = {
// ... other settings
"reporter": ["text"],
"report-dir": "./coverage" // will generate a file ./coverage/text.txt
}
module.exports = function(config) {
config.set({
// ... other settings
reporters: ['coverage'],
coverageReporter: {
type : 'text',
dir: './coverage',
file: 'coverage.txt'
}
});
};