> ## Documentation Index
> Fetch the complete documentation index at: https://docs.talosjs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# coverage

> Run Bun test suites with coverage and report uncovered modules

Runs each selected Bun test suite with coverage enabled, parses Bun's coverage table or `lcov.info`, and prints modules ranked by failing or lowest coverage. It can also create local issue YAML files for failing or under-covered modules.

## Usage

```bash theme={null}
talos coverage [options]
```

## Examples

Measure every module that has a test suite:

```bash theme={null}
talos coverage
```

Measure one module and show failing suite output:

```bash theme={null}
talos coverage --modules=user --logs
```

Use a lower coverage threshold:

```bash theme={null}
talos coverage --threshold=75
```

Fail when any passing suite stays under the threshold:

```bash theme={null}
talos coverage --strict
```

Create issue YAML files for coverage problems:

```bash theme={null}
talos coverage --issues
```

## Options

| Option          | Description                                                                             | Default                   |
| --------------- | --------------------------------------------------------------------------------------- | ------------------------- |
| `--issues`      | Create a YAML issue per under-covered or failing module instead of printing the report. | `false`                   |
| `--modules`     | Only run modules whose directory name matches the comma-separated list.                 | All measurable modules    |
| `--packages`    | Alias for `--modules`.                                                                  | All measurable modules    |
| `--threshold`   | Minimum line and function coverage a module must reach, in percent.                     | `90`                      |
| `--logs`        | Print the output of every suite that fails.                                             | `false`                   |
| `--concurrency` | Number of suites to run at once.                                                        | Core count, capped at `8` |
| `--no-cache`    | Skip reading and writing the coverage cache.                                            | `false`                   |
| `--strict`      | Exit non-zero for modules under the threshold, not only failing suites.                 | `false`                   |
| `--cwd`         | Working directory.                                                                      | Current directory         |

## Execution

A measurable module needs a `package.json` and a `tests/` directory. The command runs Bun suites with:

```bash theme={null}
bun test tests --coverage --coverage-reporter=text
```

If Bun does not print a coverage table, the command falls back to `lcov.info` in the module's configured `coverageDir`, or `coverage/` when no `coverageDir` is configured.

## Output

The report prints one row per run suite, line and function coverage rates, failing suites, and the least-covered files under the threshold. Without `--logs`, failing suites tell you to re-run with `--logs`; with `--logs`, the report includes the tail of each failing suite's output.

## Caching

Coverage entries live in `var/cache/coverage/<module>.json`. A cached entry is reused only when the module, its workspace dependencies, and selected root files still match. Only suites that reported coverage are stored. `--no-cache` disables reading and writing the cache.

## Issues

With `--issues`, the command writes one `Todo` issue into each affected module's `issues/` directory. Failing suites are labeled `Bug`; under-covered passing suites are labeled `Testing`.

## Exit codes

A failing or errored suite exits non-zero. A passing suite under the threshold exits non-zero only with `--strict`.
