# Testing

> Test chain: PHP standalone, PHPStan, and JS (Mocha)

---

The full chain runs with:

```bash
npm test
```

which executes `test:php` → `analyse:php` → `test:js`, each step required to pass before the next runs.

## JavaScript (Mocha + jsdom)

```bash
npm run test:js
# mocha 'resources/js/tests/**/*.test.js' --require jsdom-global/register
```

## PHP standalone unit tests

```bash
npm run test:php
# runs every tests/test-*.php with the system PHP — no webtrees install, no DB
```

| Test | Covers |
| --- | --- |
| <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/tests/test-text-tag-collector.php" target="_blank" rel="noopener"><code>test-text-tag-collector.php</code></a>
 | text-tag collector |
| <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/tests/test-link-classifier.php" target="_blank" rel="noopener"><code>test-link-classifier.php</code></a>
 | link classifier (incl. target extraction) |
| <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/tests/test-uid-tag-collector.php" target="_blank" rel="noopener"><code>test-uid-tag-collector.php</code></a>
 | UID tag collector |
| <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/tests/test-uid-index-service.php" target="_blank" rel="noopener"><code>test-uid-index-service.php</code></a>
 | UID index service |
| <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/tests/test-i18n-mark.php" target="_blank" rel="noopener"><code>test-i18n-mark.php</code></a>
 | i18n markers |
| <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/tests/test-wthb-toc-service.php" target="_blank" rel="noopener"><code>test-wthb-toc-service.php</code></a>
 | WTHB TOC service |

## PHP static analysis

```bash
npm run analyse:php      # or: composer analyse
# PHPStan Level 6 — see the PHPStan page
```

## Smoke tests (need webtrees + DB)

These exercise a real installation and are **not** part of `npm test`:

```bash
php tests/smoke-text-tag-collector.php [limit]
php tests/smoke-migration5.php
php tests/p1-measure.php [--tree=<id>]
```
