Skip to content
This repository was archived by the owner on Nov 1, 2025. It is now read-only.

Commit 872c105

Browse files
authored
feat: allow specifying a test command
2 parents c942c2c + 6f8b71a commit 872c105

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
github-token:
99
description: "Github token"
1010
required: true
11+
test-command:
12+
description: "Specify a command to run the tests"
13+
required: false
1114
runs:
1215
using: "node12"
1316
main: "index.js"

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const main = async () => {
66
const repoName = context.repo.repo;
77
const repoOwner = context.repo.owner;
88
const githubToken = core.getInput("github-token");
9+
const testCommand = core.getInput("test-command") || "npx jest";
910

1011
const githubClient = new GitHub(githubToken);
1112
const commitPRs = await githubClient.repos.listPullRequestsAssociatedWithCommit(
@@ -17,7 +18,7 @@ const main = async () => {
1718
);
1819
const prNumber = commitPRs.data[0].number;
1920

20-
const codeCoverage = execSync("npx jest").toString();
21+
const codeCoverage = execSync(testCommand).toString();
2122
let coveragePercentage = execSync(
2223
"npx coverage-percentage ./coverage/lcov.info --lcov"
2324
).toString();

readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ This action comments a pull request with the jest code coverage
1010

1111
**Required** Github token.
1212

13+
### `test-command`
14+
15+
**Optional** A custom command to run the tests. (defaults to `npx jest` if not specified)
16+
1317
## Example usage
1418

1519
```yml
1620
uses: ziishaned/jest-reporter-action@v0.0.1
1721
with:
18-
github-token: 'github-token'
19-
```
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
test-command: "yarn jest --coverage"
24+
```

0 commit comments

Comments
 (0)