This file explains the current test suite, what each test file validates, and how to run tests reliably.
The supported implementation path is the extended pipeline. Legacy tests remain in the repository as historical/reference coverage, but they are skipped because legacy behavior is deprecated and should not drive new work.
tests/extended.foundation.test.tstests/cli.extended.test.tstests/helpers/temp.ts(shared helper, not a test suite)
tests/core.legacy.test.ts(skipped)tests/cli.legacy.test.ts(skipped)tests/faultfinding.rigorous.test.ts(skipped)
Run all tests:
bun testRun the supported extended suite:
bun test tests/extended.foundation.test.ts tests/cli.extended.test.tsRun a single suite:
bun test tests/extended.foundation.test.ts
bun test tests/cli.extended.test.tsRecommended sanity checks after test updates:
bun run build
bun run lintPurpose: validate the extended pipeline's core foundation behavior.
Coverage:
- Binary detection using the null-byte sampling heuristic.
- Deterministic token counting.
- Summary filename resolution and validation.
- Deterministic tree formatting.
- Escaping file content that could break XML-like framing.
- Writing summary files under
.kontxt/. - Split summary generation within final rendered token budgets.
- Stale split markdown cleanup.
- Unified ignore behavior, including
.kontxtignore. - Traversal protection.
- Per-file read error isolation.
- Extended pipeline report metadata.
Purpose: smoke-test built CLI behavior for the supported extended path.
Coverage:
kontxt -tprints tree-only output and does not write.kontxt.kontxt -e -ocreates the default dated summary file.kontxt -e -o <name>appends.mdwhen missing.- Invalid output path segments fail with a validation error.
kontxt -e --32k,--64k, and--128kroute to split directories.- Split flags require
-e. - Split flags cannot be combined with
-o.
Implementation details:
- Builds
dist/index.jsinbeforeAll. - Uses temp workspace directories for each test.
- Uses a bootstrap runner with frozen
Datefor deterministic default filename assertions.
Purpose: validate deterministic legacy behavior of core functions.
Coverage:
- Tree formatting helpers:
buildTreerenderTreeformatTree
- Context serialization:
formatContextoutput shape (<tree>,<file path="...">)
- Summary writing:
- default dated filename when output name is omitted
- custom filename under
.kontxt/ - invalid filename rejection (
"",.,..,nested/custom.md)
- Discovery/read behaviors:
- ignore rules in
getFiles - unknown extension + extensionless files are included where expected
readOneFilemetadata/content assertionsreadAllFileshappy path- explicit read failure scenarios (directory input, unreadable file)
- ignore rules in
Time handling:
- Date is frozen for deterministic default filename assertion.
Purpose: smoke-test built CLI behavior at process level.
Coverage:
kontxt(no args) prints utility info and exits success.kontxt -ocreates default dated summary file.kontxt -o custom.mdcreates custom summary file.kontxt -o nested/custom.mdexits non-zero with validation error.
Implementation details:
- Builds
dist/index.jsinbeforeAll. - Uses temp workspace directories for each test.
- Uses a bootstrap runner with frozen
Datefor deterministic-odefault filename.
Purpose: stronger fault-finding/security-hardening expectations beyond current legacy baseline.
Checks included:
- path traversal protection in
readOneFile - per-file read failure isolation in
readAllFiles - binary-file skipping
- escaping content that can break
<file>framing - ignore-policy consistency between discovery and tree generation
- deterministic tree rendering regardless of input order
- output filename control-character rejection
Important:
- This suite identifies historical legacy gaps.
- Do not use it as the acceptance target for new extended work unless a legacy gap is intentionally being ported into extended coverage.
Shared utilities:
- create isolated temp directories
- clean up temp directories
- create fixture files with parent directories
This keeps tests isolated from repo state and avoids writing to source paths.
- Supported path confidence:
extended.foundation+cli.extended. - Legacy suites are retained as reference material only.
- New work should add or update extended tests, not legacy tests.