fix TSamNearest and fully support jump Keymap
All checks were successful
tests / test (push) Successful in 10s

This commit is contained in:
2026-01-05 08:58:48 +01:00
parent 7218ed0c4c
commit 29ddc34add
5 changed files with 736 additions and 169 deletions

View File

@@ -6,10 +6,10 @@ Mocha.js runner for the test-samurai Neovim plugin.
- Detects Mocha test files by checking `package.json` dependencies.
- Supports nearest, file, all, and failed-only commands.
- Streams results via Mocha's `json-stream` reporter.
- Streams results via a custom NDJSON reporter.
- Provides quickfix locations and per-test output.
- Uses `--grep` with escaped patterns to match titles safely, even when running through `npm test`.
- Executes tests via `npx mocha` for direct Mocha invocation.
- Executes tests via `npx mocha` with the bundled UI + reporter so projects need no extra setup.
- `TSamAll` runs `test/**/*.{test,spec}.{t,j}s` to discover tests reliably.
## Full Name Convention
@@ -25,21 +25,30 @@ This convention is used consistently in `results.*`, `parse_test_output`, and
`collect_failed_locations`. Failed-only runs translate `/` back to spaces for
Mocha's `--grep` matching. Avoid `/` in your titles if you rely on that mapping.
When the custom reporter provides `titlePath`, it is used to build full names
without ambiguity (titles may contain spaces).
## Reporter Payload
The runner expects Mocha's built-in `json-stream` reporter, which emits one JSON
object per line. It consumes the following fields when present:
The runner uses the bundled NDJSON reporter at `scripts/mocha-ndjson-reporter.cjs`,
which emits one JSON object per line:
```
{
"event": "suite" | "suite end" | "pass" | "fail" | "pending",
"event": "run-begin" | "run-end" | "suite" | "test",
"status": "passed" | "failed" | "pending" | "skipped",
"title": "Test or suite title",
"fullTitle": "Mocha full title",
"titlePath": ["Parent", "Child", "Test"],
"file": "/path/to/test.js",
"err": { "message": "string", "stack": "string" }
"location": { "file": "/path/to/test.js", "line": 10, "column": 5 },
"error": { "message": "string", "stack": "string" }
}
```
The UI wrapper `scripts/bdd-with-location.cjs` attaches test/suite locations so
Quickfix and per-test output are consistent.
## Usage
Add the module to your test-samurai configuration: