|
| 1 | +--- |
| 2 | +title: Configuration |
| 3 | +description: Documentation for the action's configuration. Described all inputs with examples. |
| 4 | +--- |
| 5 | + |
| 6 | +import CoverageAnnotationExample from 'assets/coverage-annotation-example.jpg'; |
| 7 | +import FailedTestAnnotationExample from 'assets/failed-test-annotation-example.jpg'; |
| 8 | + |
| 9 | +# Configuration |
| 10 | + |
| 11 | +Jest Coverage Report action's configuration is created in the same way as for [any other GitHub action](https://www.github.com/features/actions). |
| 12 | + |
| 13 | +## github-token |
| 14 | + |
| 15 | +GitHub token. Required parameter. By default, you can use standard GitHub-provided token: `${{ secrets.GITHUB_TOKEN }}`. Example: |
| 16 | + |
| 17 | +```yaml |
| 18 | +- uses: artiomtr/jest-coverage-report-action@v2 |
| 19 | + with: |
| 20 | + github-token: \${{ secrets.GITHUB_TOKEN }} |
| 21 | +``` |
| 22 | +
|
| 23 | +## threshold |
| 24 | +
|
| 25 | +If you want to set minimal accepted coverage for the PR, you can pass and optional parameter threshold. |
| 26 | +
|
| 27 | +For example, if you want to reject every pull request, with total line coverage less than 80%: |
| 28 | +
|
| 29 | +```yaml |
| 30 | +- uses: artiomtr/jest-coverage-report-action@v2 |
| 31 | + with: |
| 32 | + threshold: 80 # if coverage < 80%, action will fail |
| 33 | +``` |
| 34 | +
|
| 35 | +## working-directory |
| 36 | +
|
| 37 | +If you want to run this action in custom directory, specify `working-directory`: |
| 38 | + |
| 39 | +```yaml |
| 40 | +with: |
| 41 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + working-directory: <dir> |
| 43 | +``` |
| 44 | + |
| 45 | +## test-script |
| 46 | + |
| 47 | +By default, action will run this command, to extract coverage: |
| 48 | + |
| 49 | +```bash |
| 50 | +npx jest --silent --ci --coverage --testLocationInResults --json --outputFile="report.json" |
| 51 | +``` |
| 52 | + |
| 53 | +If you're not satisfied with default behaviour, you can specify your own command, by passing custom option `test-script`. |
| 54 | + |
| 55 | +<!-- TODO: replace link --> |
| 56 | + |
| 57 | +**⚠ IMPORTANT: The test script must generate output in a specific format. For more information, see [docs](https://github.com/ArtiomTr/jest-coverage-report-action#customizing-test-script).** |
| 58 | + |
| 59 | +For instance, if you want to run `test:coverage` npm script: |
| 60 | + |
| 61 | +```yaml |
| 62 | +with: |
| 63 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + test-script: npm run test:coverage |
| 65 | +``` |
| 66 | + |
| 67 | +## icons |
| 68 | + |
| 69 | +If you don't satisfied with the standard icons, you can replace them with `icons` input. Example: |
| 70 | + |
| 71 | +```yaml |
| 72 | +with: |
| 73 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + icons: ascii |
| 75 | +``` |
| 76 | + |
| 77 | +Available options: `emoji` (standard), `ascii`, `unicode`. |
| 78 | + |
| 79 | +## annotations |
| 80 | + |
| 81 | +Annotations are enabled by default. To disable them, specify `annotations: none`. For instance: |
| 82 | + |
| 83 | +```yaml |
| 84 | +with: |
| 85 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 86 | + annotations: none |
| 87 | +``` |
| 88 | + |
| 89 | +If you want to enable only specific annotations, you can specify following choices: |
| 90 | + |
| 91 | +### `annotations: coverage` |
| 92 | + |
| 93 | +<ResponsiveImage width="100%" images={CoverageAnnotationExample.images} /> |
| 94 | + |
| 95 | +### `annotations: failed-tests` |
| 96 | + |
| 97 | +<ResponsiveImage width="100%" images={FailedTestAnnotationExample.images} /> |
| 98 | + |
| 99 | +### package-manager |
| 100 | + |
| 101 | +By default, action uses [npm](https://github.com/npm/cli#readme) package manager. But, if you want to use [yarn](https://github.com/yarnpkg/berry#readme), simply set `package-manager: yarn` option: |
| 102 | + |
| 103 | +```yaml |
| 104 | +with: |
| 105 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + package-manager: yarn |
| 107 | +``` |
| 108 | + |
| 109 | +### skip-step |
| 110 | + |
| 111 | +If you've installed dependencies in previous step, or you already have `report.json` file, you can skip `install` or `all` steps. For instance: |
| 112 | + |
| 113 | +```yaml |
| 114 | +with: |
| 115 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + skip-step: install |
| 117 | +``` |
0 commit comments