Skip to content

Commit

Permalink
Merge pull request #307 from dkhunt27/diffToFixed
Browse files Browse the repository at this point in the history
handled diff.ToFixed too
  • Loading branch information
dkhunt27 authored Sep 21, 2023
2 parents 9ea8ef2 + 09b78e7 commit bd37cb7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The report is based on the coverage report generated by your test runner.
- `npm run all`
- `git commit/push changes`
- make PR back to main
- wait for pipelines to finish (test will always finish with an error since this isn't a nx monorepo)
- wait for pipelines to finish; then merge
- `git checkout main`
- `git pull`
- `git tag v1`
Expand Down
16 changes: 14 additions & 2 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.

20 changes: 17 additions & 3 deletions src/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export const buildComment = ({results}: BuildCommentInputs): string => {
let arrow = ''
let diffHtml = ''

if (result.diff !== null) {
// when no tests, not sure if output is undefined or 'Unknown'; TODO: add test case
if (
result.diff !== undefined &&
result.diff !== null &&
(result.diff as unknown) !== 'Unknown'
) {
if (result.diff < 0) {
arrow = '▾'
} else if (result.diff > 0) {
Expand All @@ -35,8 +40,17 @@ export const buildComment = ({results}: BuildCommentInputs): string => {

const htmlResults = tabulate(result.details)

const coverage =
result.coverage === undefined ? 'unknown' : result.coverage.toFixed(2)
// when no tests, not sure if is undefined or 'Unknown'; TODO: add test case
let coverage
if (
result.coverage === undefined ||
result.coverage === null ||
(result.coverage as unknown) === 'Unknown'
) {
coverage = 'unknown'
} else {
coverage = result.coverage.toFixed(2)
}

return `${table(
tbody(tr(th(result.app), th(coverage, '%'), diffHtml))
Expand Down

0 comments on commit bd37cb7

Please sign in to comment.