Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,15 @@ with:
working-directory: "frontend"
```

### Hide details in coverage comment

```yaml
uses: mattallty/jest-github-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# To hide details in coverage comment
hide-details: true
```

See the [actions tab](https://github.com/mattallty/jest-github-action/actions) for runs of this action! :rocket:
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ inputs:
check-name:
description: "Status check name"
required: true
hide-details:
description: "Hide details in coverage comment"
required: false
default: "false"

runs:
using: "node12"
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function shouldRunOnlyChangedFiles(): boolean {
return Boolean(JSON.parse(core.getInput("changes-only", { required: false })))
}

function shouldHideDetails(): boolean {
return Boolean(JSON.parse(core.getInput("hide-details", { required: false })))
}

export function getCoverageTable(
results: FormattedTestResults,
cwd: string,
Expand All @@ -112,7 +116,12 @@ export function getCoverageTable(
])
}

return COVERAGE_HEADER + table(rows, { align: ["l", "r", "r", "r", "r"] })
let comment = COVERAGE_HEADER + table(rows, { align: ["l", "r", "r", "r", "r"] })
if (shouldHideDetails()) {
comment = COVERAGE_HEADER + "<details>\n\n" + table(rows, { align: ["l", "r", "r", "r", "r"] }) + "\n\n</details>"
}

return comment
}

function getCommentPayload(body: string) {
Expand Down