# npm quickstart

> Run every quelltest command on a small Jest project and read the real output, from finding risky edges to gating a change that weakens tests.

Canonical page: https://quelltest.com/docs/npm/quickstart

This walkthrough runs the five everyday quelltest commands in order on a small Jest project: find risky untested edges, score them against coverage, generate tests, verify that a test catches bugs, and gate a change that weakens tests. Every output below was produced by quelltest 0.3.1 on Node.js 24.11. Paths are shortened and the `[copy]` marker means verification ran in a temporary copy of the project.

The sample project has `src/pay.js` (a `charge` function with two guards and an `applyDiscount` function with `pct || 10`), `src/files.js` (an Express-style handler that reads `req.query.name` from disk), `src/shipping.js` (a function with `typeof` and `> 30` guards) and `tests/pay.test.js` with three Jest tests.

## 1. How do I get coverage data?

`score` and the coverage filter of `find` read Istanbul `coverage-final.json` (or `lcov.info`; see the note below). With Jest:

```bash
npx jest --coverage --coverageReporters=json
```

This writes `coverage/coverage-final.json`. quelltest also auto-detects `coverage/coverage-final.json` and `coverage/lcov.info` in the current directory.

> **lcov paths:** in 0.3.1 an `lcov.info` whose `SF:` lines are relative (as Jest and Node's built-in reporter write them) is resolved against the folder of the lcov file, so nothing matches and the score is `0/100`. Use `coverage-final.json`, or an lcov file with absolute `SF:` paths. See [limits and known issues](https://quelltest.com/docs/npm/limits.md).

## 2. How do I find risky untested edges?

```bash
npx quell find src --coverage coverage/coverage-final.json
```

```text
Quell scan — 9 edge-case candidates not executed by tests (2 already covered), showing 9
• src/files.js:4 [path-traversal] download — request value reaches a file path; test "../" and absolute paths and use path.basename or a base-directory check (high)
• src/pay.js:3 [throws] charge — assert the error type and message ("insufficient funds") (high)
• src/shipping.js:2 [throws] shippingCost — assert the error type and message ("weight must be a number") (high)
• src/shipping.js:3 [throws] shippingCost — assert the error type and message ("parcel too heavy") (high)
• src/pay.js:3 [boundary] charge — test the boundary and its adjacent values (medium)
• src/pay.js:8 [falsy-fallback] applyDiscount — `||` also replaces 0; test 0 and use `??` where 0 is valid (medium)
• src/shipping.js:3 [boundary] shippingCost — test the boundary and its adjacent values (medium)
• src/shipping.js:2 [nullish] shippingCost — test null, undefined, and the populated path (low)
• src/shipping.js:4 [boundary] shippingCost — test the boundary and its adjacent values (low)
```

Each line is `file:line [rule-or-category] function — suggestion (confidence)`. They are sorted by risk, highest first. The two candidates your tests already run (the `amount <= 0` guard) are hidden because coverage evidence was given. Add `--all` to see them, `--top N` to change how many print, `--json` or `--sarif` for machine-readable output. The [rule pack](https://quelltest.com/docs/npm/rules.md) explains every rule id.

## 3. How do I get a score?

```bash
npx quell score src --coverage coverage/coverage-final.json
```

```text
Score: 18/100 edge-cases-uncovered | 2/11 candidates executed by tests | coverage evidence: istanbul
```

The score is the share of candidates your tests execute: 2 of 11 is 18. Without coverage evidence quelltest prints `not scored` instead of `0/100`.

Add `--threshold 60` to make the command fail the build when the score is too low:

```bash
npx quell score src --coverage coverage/coverage-final.json --threshold 60
echo $?
```

```text
Score: 18/100 edge-cases-uncovered | 2/11 candidates executed by tests | coverage evidence: istanbul
1
```

Tiers: 80 and above is `production-ready`, 60 to 79 is `review-needed`, below 60 is `edge-cases-uncovered`.

## 4. How do I generate tests?

```bash
npx quell generate src/shipping.js --verify --write
```

```text
Wrote 2 tests (2 verified), 1 TODO notes, 2 flagged, 0 already covered
  TODO src/shipping.js:4 — the guard body does not start with `throw new Error(...)` or `return <literal>` (and there is no literal `@example` to use)
```

`generate` only writes a test when it can derive one from a guard it can analyse statically (parameters compared with literals, `typeof` checks, truthiness, JSDoc `@example`). Everything else becomes a Markdown TODO note, never a placeholder test. With `--verify` a test is kept only if it passes on the original code and fails on a mutant of the source. Files go to `tests/quelltest/` by default, named by finding id:

```text
tests/quelltest/7d915d39599a.test.js
tests/quelltest/8bee363b6f89.test.js
tests/quelltest/99de889e7c7f.todo.md
```

One generated assertion, for the `weightKg > 30` guard:

```js
it("rejects weightKg = 31", () => {
  expect(() => shippingCost(31, "USx")).toThrow("parcel too heavy");
});
```

Without `--write`, `generate` is a dry run that only prints what it would do. See [code that calls APIs](https://quelltest.com/docs/npm/dependencies.md) for how it builds stubs.

## 5. How do I check that a test catches bugs?

```bash
npx quell verify tests/pay.test.js --source src/pay.js --runner jest --handoff quell-handoff.md
```

```text
Verified: test killed 4/11 mutants (36%) [copy]
  survived: || -> ?? (0 no longer falls back) (line 8)
  survived: guard removed (line 3)
  survived: throw removed (line 3)
  survived: > -> >= (line 3)
  survived: || -> && (line 8)
  survived: - -> + (line 9)
  survived: * -> / (line 9)
Handoff written to quell-handoff.md
```

`Verified` means the test passed on the original code, contains an assertion that observes the code, and failed on at least one mutant. It does not mean the test is strong: it killed 4 of 11. The seven survivors are the places where the test would not notice a bug. `quell-handoff.md` lists each one with the source diff and an instruction an agent or a person can act on. Add `--min-score 60` to also require that 60% of decided mutants are killed (the command then exits 4). Note `--runner jest`: `verify` defaults to `node:test`. The mechanics are in [how verify works](https://quelltest.com/docs/npm/verify.md).

## 6. How do I check that a change did not weaken tests?

On a branch that loosens `toBe(70)` to `toBeTruthy()`, skips one test and deletes another:

```bash
npx quell gate --diff main
echo $?
```

```text
Gate failed: 3 issue(s) in 1 changed test file(s)
  ✖ tests/pay.test.js :: charge returns something — test deleted
  ✖ tests/pay.test.js :: charge subtracts the amount — assertions weakened (0 -> 1 weak, e.g. equality replaced by ok/truthy/not-null)
  ✖ tests/pay.test.js :: charge rejects zero — test is now skipped (skip/todo/x-prefixed)
5
```

Exit code 5 means weakened tests were found. See [the test gate](https://quelltest.com/docs/npm/gate.md) for everything it detects.

## 7. How do I limit findings to my change?

On the same branch, a new `refund` function was added to `src/pay.js`:

```bash
npx quell find src --diff main --coverage coverage/coverage-final.json
```

```text
Quell scan — 2 edge-case candidates not executed by tests (0 already covered), showing 2
• src/pay.js:15 [throws] refund — assert the error type and message ("refund needs approval") (high)
• src/pay.js:15 [boundary] refund — test the boundary and its adjacent values (medium)
```

`--diff REF` keeps only candidates on lines changed since the merge-base with `REF` (including uncommitted and untracked files). Next, put `gate` and `find --diff` into pull requests with the [CI guide](https://quelltest.com/docs/npm/ci.md).
