Skip to content

Build your personal knowledge base with Trilium Notes

docs: scope local test runs to targeted specs, never ESLint or full suites

Elian Doranec6afc8b5163
diff --git a/.claude/skills/analyzing-coverage/SKILL.md b/.claude/skills/analyzing-coverage/SKILL.md
index d83fa4043c..7b522ab1c6 100644
--- a/.claude/skills/analyzing-coverage/SKILL.md
+++ b/.claude/skills/analyzing-coverage/SKILL.md
@@ -7,6 +7,11 @@ description: Use when measuring or chasing Vitest/v8 code coverage in the Triliu
There is **one** coverage analyzer — `coverage.mjs` in this skill folder. Don't write a new throwaway parser; every past session that did (`cov-analyze.mjs`, `cov-parse.mjs`, `cov-lines.mjs`, `cov-gaps.cjs`) reinvented the same two operations. Use this instead.
+> **Analyzing existing coverage data is free; producing it is not.** A coverage run is a full suite run
+> plus instrumentation — minutes, and normally CI's job. Prefer whatever `lcov.info` is already on
+> disk, and when you do need fresh numbers, scope the run to the package or path in question rather
+> than running `pnpm coverage`. Generating repo-wide coverage is an explicit-request activity.
+
```
node .claude/skills/analyzing-coverage/coverage.mjs <coverage-file> [summary|gaps] [options]
```
diff --git a/.claude/skills/ckeditor5-testing/SKILL.md b/.claude/skills/ckeditor5-testing/SKILL.md
index 99dfbc1f77..90f7d4487c 100644
--- a/.claude/skills/ckeditor5-testing/SKILL.md
+++ b/.claude/skills/ckeditor5-testing/SKILL.md
@@ -80,9 +80,11 @@ Debug a browser-mode package with a visible browser:
vitest --inspect-brk --no-file-parallelism --browser.headless=false
```
-Root orchestration: `pnpm test:parallel` runs the light packages in parallel; `pnpm
-test:sequential` runs `ckeditor5` **sequentially** (browser resource
-limits), alongside the server. `pnpm test:all` runs both. Each package exposes `"test": "vitest"` and
+Root orchestration — **what CI runs, not what you run.** `pnpm test:parallel` runs the light
+packages in parallel; `pnpm test:sequential` runs `ckeditor5` **sequentially** (browser resource
+limits), alongside the server. `pnpm test:all` runs both. All three take minutes; during development
+run a filtered package suite instead (`pnpm --filter @triliumnext/ckeditor5 test <pattern>`), and
+leave the aggregates to CI. Each package exposes `"test": "vitest"` and
`"test:debug": "vitest --inspect-brk --no-file-parallelism --browser.headless=false"`.
**When the downloaded browser cannot run** — on NixOS the Chrome for Testing build and chromedriver
diff --git a/.claude/skills/writing-unit-tests/SKILL.md b/.claude/skills/writing-unit-tests/SKILL.md
index bb359ff684..1216645516 100644
--- a/.claude/skills/writing-unit-tests/SKILL.md
+++ b/.claude/skills/writing-unit-tests/SKILL.md
@@ -28,6 +28,15 @@ Also follow `CLAUDE.md`: write **concise** tests (group related assertions in on
## Running tests
+> **Run the narrowest thing that covers the change, and never the full suite.** `pnpm test:all`,
+> `test:parallel`, `test:sequential` and `pnpm coverage` take minutes and are CI's job — reach for one
+> only if the user asks. **Never run ESLint** either (`pnpm dev:linter-check`/`-fix`, `npx eslint`): it
+> currently dies out-of-memory, so a run costs minutes and tells you nothing. Typecheck with
+> `pnpm typecheck` (never a raw `tsc -p`/`tsc -b`, which misses the project references) — cheaper than a
+> suite, but not instant, so run it once a change is finished rather than after every edit.
+
+- Filtered (preferred): `pnpm --filter <pkg> test <path-or-pattern>` — the trailing argument is a
+ substring filter over spec paths, so `pnpm --filter server test special_notes` runs every match.
- Whole package: `pnpm --filter <pkg> test` (e.g. `@triliumnext/client`, `@triliumnext/server`, `@triliumnext/commons`).
- Single file (server): `pnpm --filter server test spec/etapi/search.spec.ts`
- Single file (client): `pnpm --filter @triliumnext/client exec vitest run src/widgets/react/Button.spec.tsx`
diff --git a/CLAUDE.md b/CLAUDE.md
index 3a053840b4..84d4247775 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -22,16 +22,14 @@ pnpm client:build # Frontend
pnpm server:build # Backend
pnpm desktop:build # Electron
-# Test
-pnpm test:all # All tests (parallel + sequential)
+# Test — run the narrowest thing that covers your change (see below)
+pnpm --filter server test <path-or-pattern> # One package, filtered
+pnpm test:all # All tests (parallel + sequential) — CI's job, not yours
pnpm test:parallel # Client + most package tests
pnpm test:sequential # Server (shared DB) + browser-mode tests (ckeditor5)
-pnpm --filter server test # Single package tests
pnpm coverage # Coverage reports
# Lint & Format
-pnpm dev:linter-check # ESLint check
-pnpm dev:linter-fix # ESLint fix
pnpm dev:format-check # Format check (stricter stylistic rules)
pnpm dev:format-fix # Format fix
pnpm typecheck # TypeScript type check across all projects
@@ -39,6 +37,15 @@ pnpm typecheck # TypeScript type check across all projects
**Running a single test file**: `pnpm --filter server test spec/etapi/search.spec.ts`
+### Do not run full suites or ESLint
+
+- **Never run ESLint** — `pnpm dev:linter-check`, `dev:linter-fix`, or `npx eslint` on any path. It currently dies with an out-of-memory error, so a run tells you nothing and costs minutes. CI lints. (Note `packages/*` is globally ignored by the ESLint config anyway, so most of `trilium-core` was never linted locally to begin with.)
+- **Never run `pnpm test:all`, `test:parallel`, `test:sequential`, or `pnpm coverage`** during development. They take a long time, and CI runs them on every push.
+- **Run the narrowest suite that covers what you touched**, and iterate on that: `pnpm --filter <pkg> test <path-or-pattern>`. Vitest treats the trailing argument as a substring filter over test file paths, so `pnpm --filter server test special_notes` runs every matching spec.
+- **Typecheck with `pnpm typecheck`, not a raw `tsc` invocation.** It resolves the project references and per-project configs that a hand-written `tsc --noEmit -p …` or `tsc -b …` gets wrong. It is cheaper than a suite but not instant, so run it when you've finished a change — not after every edit.
+- Core specs are the one case where "narrowest" means **two** commands: they run under both the server and standalone suites (see Testing below), so a targeted run against each is still the right scope.
+- Only reach for a full suite if the user asks, or when the work is finished and they want a final check.
+
## Git Workflow
- **Committing directly on `main` is allowed and expected** for small fixes and self-contained features — do **not** create a branch first for those. The default "branch before committing on the default branch" rule does not apply to this repository.