Skip to content

Commit

Permalink
Remove links (#26)
Browse files Browse the repository at this point in the history
* add remove-links-to-tiles to readme

* add removeLinksToFiles to options

* add removeLinksToFiles to code

* add tips when comment is too long

* bump dependencies

* build

* add tests for removeLinksToFiles

* 1.0.14
  • Loading branch information
MishaKav authored Aug 19, 2022
1 parent c796cdd commit c90619d
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 106 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ You can add this action to your GitHub workflow for Ubuntu runners (e.g. `runs-o
| `hide-summary` | | false | Hide coverage summary report |
| `create-new-comment` | | false | When false, will update the same comment, otherwise will publish new comment on each run. |
| `hide-comment` | | false | Hide the whole comment (use when you need only the `output`). Useful for auto-update bagdes in readme. |
| `remove-links-to-files` | | false | Remove links to files (useful when summary-report is too big) |
| `remove-links-to-lines` | | false | Remove links to lines (useful when summary-report is too big) |
| `junitxml-path` | | '' | The location of the junitxml path (npm package `jest-junit` should be installed) |
| `junitxml-title` | | '' | Title for summary for junitxml |
| `coverage-path` | | '' | The location of the coverage.txt (jest console output) |
Expand Down
34 changes: 34 additions & 0 deletions __tests__/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ describe('get coverage report', () => {
expect(statements).toBe(70)
})

test('should return coverage report without links to files', () => {
const html = `<details><summary>Coverage Report (<b>71%</b>)</summary><table><tr><th>File</th><th>% Stmts</th><th>% Branch</th><th>% Funcs</th><th>% Lines</th><th>Uncovered Line #s</th></tr><tbody><tr><td><b>All files</b></td><td><b>70.21</b></td><td><b>100</b></td><td><b>28.57</b></td><td><b>71.73</b></td><td>&nbsp;</td></tr><tr><td>src</td><td>68.29</td><td>100</td><td>33.33</td><td>68.29</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;controller.js</td><td>46.66</td><td>100</td><td>33.33</td><td>46.66</td><td><a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/controller.js#L5-L9">5&ndash;9</a>, <a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/controller.js#L23-L27">23&ndash;27</a></td></tr><tr><td>&nbsp; &nbsp;index.js</td><td>85.71</td><td>100</td><td>0</td><td>85.71</td><td><a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/index.js#L9">9</a></td></tr><tr><td>&nbsp; &nbsp;router.js</td><td>100</td><td>100</td><td>100</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;service.js</td><td>69.23</td><td>100</td><td>50</td><td>69.23</td><td><a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/service.js#L16-L20">16&ndash;20</a></td></tr><tr><td>src/utils</td><td>83.33</td><td>100</td><td>0</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;config.js</td><td>100</td><td>100</td><td>100</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;utils.js</td><td>75</td><td>100</td><td>0</td><td>100</td><td>&nbsp;</td></tr></tbody></table></details>`

const { coverageHtml } = getCoverageReport({
...options,
removeLinksToFiles: true,
})

expect(coverageHtml).toBe(html)
})

test('should return coverage report without links to lines', () => {
const html = `<details><summary>Coverage Report (<b>71%</b>)</summary><table><tr><th>File</th><th>% Stmts</th><th>% Branch</th><th>% Funcs</th><th>% Lines</th><th>Uncovered Line #s</th></tr><tbody><tr><td><b>All files</b></td><td><b>70.21</b></td><td><b>100</b></td><td><b>28.57</b></td><td><b>71.73</b></td><td>&nbsp;</td></tr><tr><td>src</td><td>68.29</td><td>100</td><td>33.33</td><td>68.29</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;<a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/controller.js">controller.js</a></td><td>46.66</td><td>100</td><td>33.33</td><td>46.66</td><td>5&ndash;9, 23&ndash;27</td></tr><tr><td>&nbsp; &nbsp;<a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/index.js">index.js</a></td><td>85.71</td><td>100</td><td>0</td><td>85.71</td><td>9</td></tr><tr><td>&nbsp; &nbsp;<a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/router.js">router.js</a></td><td>100</td><td>100</td><td>100</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;<a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/service.js">service.js</a></td><td>69.23</td><td>100</td><td>50</td><td>69.23</td><td>16&ndash;20</td></tr><tr><td>src/utils</td><td>83.33</td><td>100</td><td>0</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;<a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/utils/config.js">config.js</a></td><td>100</td><td>100</td><td>100</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;<a href="https://github.com/MishaKav/jest-coverage-comment/blob/05953710b21d222efa4f4535424a7af367be5a57/src/utils/utils.js">utils.js</a></td><td>75</td><td>100</td><td>0</td><td>100</td><td>&nbsp;</td></tr></tbody></table></details>`

const { coverageHtml } = getCoverageReport({
...options,
removeLinksToLines: true,
})

expect(coverageHtml).toBe(html)
})

test('should return coverage report without links to files and to lines', () => {
const html = `<details><summary>Coverage Report (<b>71%</b>)</summary><table><tr><th>File</th><th>% Stmts</th><th>% Branch</th><th>% Funcs</th><th>% Lines</th><th>Uncovered Line #s</th></tr><tbody><tr><td><b>All files</b></td><td><b>70.21</b></td><td><b>100</b></td><td><b>28.57</b></td><td><b>71.73</b></td><td>&nbsp;</td></tr><tr><td>src</td><td>68.29</td><td>100</td><td>33.33</td><td>68.29</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;controller.js</td><td>46.66</td><td>100</td><td>33.33</td><td>46.66</td><td>5&ndash;9, 23&ndash;27</td></tr><tr><td>&nbsp; &nbsp;index.js</td><td>85.71</td><td>100</td><td>0</td><td>85.71</td><td>9</td></tr><tr><td>&nbsp; &nbsp;router.js</td><td>100</td><td>100</td><td>100</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;service.js</td><td>69.23</td><td>100</td><td>50</td><td>69.23</td><td>16&ndash;20</td></tr><tr><td>src/utils</td><td>83.33</td><td>100</td><td>0</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;config.js</td><td>100</td><td>100</td><td>100</td><td>100</td><td>&nbsp;</td></tr><tr><td>&nbsp; &nbsp;utils.js</td><td>75</td><td>100</td><td>0</td><td>100</td><td>&nbsp;</td></tr></tbody></table></details>`

const { coverageHtml } = getCoverageReport({
...options,
removeLinksToFiles: true,
removeLinksToLines: true,
})

expect(coverageHtml).toBe(html)
})

test('should render coverage title', () => {
const optionsWithTitle = { ...options, coverageTitle: 'coverageTitle' }
const { coverageHtml, coverage } = getCoverageReport(optionsWithTitle)
Expand Down
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ inputs:
default: 'false'
required: false

remove-links-to-files:
description: 'Remove links to files (useful when summary-report is too big)'
default: 'false'
required: false

remove-links-to-lines:
description: 'Remove links to lines (useful when summary-report is too big)'
default: 'false'
required: false

create-new-comment:
description: 'When false, will update the same comment, otherwise will publish new comment on each run'
default: 'false'
Expand Down
31 changes: 28 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit c90619d

Please sign in to comment.