@mark1russell7/client-vitest 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +440 -2
  4. package/README_NEW.md +513 -0
  5. package/dist/.tsbuildinfo +1 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/module.d.ts +11 -0
  11. package/dist/module.d.ts.map +1 -0
  12. package/dist/module.js +83 -0
  13. package/dist/module.js.map +1 -0
  14. package/dist/procedures/vitest/index.d.ts +5 -0
  15. package/dist/procedures/vitest/index.d.ts.map +1 -0
  16. package/dist/procedures/vitest/index.js +5 -0
  17. package/dist/procedures/vitest/index.js.map +1 -0
  18. package/dist/procedures/vitest/list.d.ts +13 -0
  19. package/dist/procedures/vitest/list.d.ts.map +1 -0
  20. package/dist/procedures/vitest/list.js +32 -0
  21. package/dist/procedures/vitest/list.js.map +1 -0
  22. package/dist/procedures/vitest/run.d.ts +17 -0
  23. package/dist/procedures/vitest/run.d.ts.map +1 -0
  24. package/dist/procedures/vitest/run.js +110 -0
  25. package/dist/procedures/vitest/run.js.map +1 -0
  26. package/dist/procedures/vitest/stop.d.ts +13 -0
  27. package/dist/procedures/vitest/stop.d.ts.map +1 -0
  28. package/dist/procedures/vitest/stop.js +25 -0
  29. package/dist/procedures/vitest/stop.js.map +1 -0
  30. package/dist/procedures/vitest/watch.d.ts +14 -0
  31. package/dist/procedures/vitest/watch.d.ts.map +1 -0
  32. package/dist/procedures/vitest/watch.js +37 -0
  33. package/dist/procedures/vitest/watch.js.map +1 -0
  34. package/dist/register.d.ts +8 -0
  35. package/dist/register.d.ts.map +1 -0
  36. package/dist/register.js +14 -0
  37. package/dist/register.js.map +1 -0
  38. package/dist/types.d.ts +85 -0
  39. package/dist/types.d.ts.map +1 -0
  40. package/dist/types.js +80 -0
  41. package/dist/types.js.map +1 -0
  42. package/dist/vitest-cli.d.ts +10 -0
  43. package/dist/vitest-cli.d.ts.map +1 -0
  44. package/dist/vitest-cli.js +28 -0
  45. package/dist/vitest-cli.js.map +1 -0
  46. package/package.json +74 -3
  47. package/src/index.ts +3 -0
  48. package/src/module.ts +104 -0
  49. package/src/procedures/vitest/index.ts +4 -0
  50. package/src/procedures/vitest/list.ts +33 -0
  51. package/src/procedures/vitest/run.ts +145 -0
  52. package/src/procedures/vitest/stop.ts +29 -0
  53. package/src/procedures/vitest/watch.ts +46 -0
  54. package/src/register.ts +17 -0
  55. package/src/types.ts +164 -0
  56. package/src/vitest-cli.ts +28 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # @mark1russell7/client-vitest
2
+
3
+ ## 0.1.0
4
+
5
+ The first release on npm. The packages of the client monorepo have one version together.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 Mark Russell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,441 @@
1
- # Temporary Holding Version
1
+ # @mark1russell7/client-vitest
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/@mark1russell7/client-vitest?color=2346c4&label=npm)](https://www.npmjs.com/package/@mark1russell7/client-vitest)
4
+
5
+ ```sh
6
+ npm install @mark1russell7/client-vitest
7
+ ```
8
+
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue.svg)](https://www.typescriptlang.org/)
11
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D22-green.svg)](https://nodejs.org/)
12
+ [![Vitest](https://img.shields.io/badge/Vitest-3.x-6E9F18.svg)](https://vitest.dev/)
13
+
14
+ > Vitest-specific test procedures. Run and watch tests with full coverage reporting.
15
+
16
+ > **October 2026:** `client-test` is merged into this package. `vitest.run` also returns `exitCode`, `stdout` and `stderr` (the last 64 KiB) and, with `coverage`, the coverage percentages. The new `vitest.coverage` runs with coverage and takes a `threshold` (minimum line coverage). The sections below predate the merge.
17
+
18
+ ## Table of Contents
19
+
20
+ - [Overview](#overview)
21
+ - [Installation](#installation)
22
+ - [Architecture](#architecture)
23
+ - [Quick Start](#quick-start)
24
+ - [API Reference](#api-reference)
25
+ - [vitest.run](#vitestrun)
26
+ - [vitest.watch](#vitestwatch)
27
+ - [Coverage Reporting](#coverage-reporting)
28
+ - [CLI Usage](#cli-usage)
29
+ - [Integration](#integration)
30
+ - [Requirements](#requirements)
31
+ - [License](#license)
32
+
33
+ ---
34
+
35
+ ## Overview
36
+
37
+ **client-vitest** provides procedures for running Vitest tests:
38
+
39
+ - **Test Execution** - Run tests once with configurable patterns
40
+ - **Watch Mode** - Continuous testing during development
41
+ - **Coverage Reports** - Line, branch, function, and statement coverage
42
+ - **Multiple Reporters** - Default, verbose, JSON, and JUnit output
43
+
44
+ ---
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ npm install github:mark1russell7/client-vitest#main
50
+ ```
51
+
52
+ ---
53
+
54
+ ## Architecture
55
+
56
+ ### System Overview
57
+
58
+ ```mermaid
59
+ graph TB
60
+ subgraph "Application Layer"
61
+ App[Your Application / CLI / MCP]
62
+ end
63
+
64
+ subgraph "client-vitest"
65
+ Run[vitest.run<br/>Execute tests]
66
+ Watch[vitest.watch<br/>Watch mode]
67
+ end
68
+
69
+ subgraph "Execution Layer"
70
+ Shell[client-shell<br/>shell.run]
71
+ end
72
+
73
+ subgraph "Test Runner"
74
+ Vitest[Vitest CLI<br/>npx vitest]
75
+ end
76
+
77
+ subgraph "Output"
78
+ Results[Test Results]
79
+ Coverage[Coverage Report]
80
+ end
81
+
82
+ App --> Run
83
+ App --> Watch
84
+ Run --> Shell
85
+ Watch --> Shell
86
+ Shell --> Vitest
87
+ Vitest --> Results
88
+ Vitest --> Coverage
89
+ ```
90
+
91
+ ### Test Execution Flow
92
+
93
+ ```mermaid
94
+ sequenceDiagram
95
+ participant App as Application
96
+ participant CV as client-vitest
97
+ participant Shell as client-shell
98
+ participant Vitest as Vitest CLI
99
+ participant FS as File System
100
+
101
+ App->>CV: vitest.run({ coverage: true })
102
+ CV->>CV: Build CLI args
103
+ CV->>Shell: shell.run("npx", ["vitest", "run", "--coverage"])
104
+ Shell->>Vitest: Execute vitest
105
+
106
+ loop For each test file
107
+ Vitest->>FS: Read test file
108
+ Vitest->>Vitest: Execute tests
109
+ end
110
+
111
+ Vitest->>FS: Write coverage report
112
+ Vitest-->>Shell: Exit code + stdout
113
+ Shell-->>CV: Command result
114
+ CV->>CV: Parse output
115
+ CV-->>App: { passed, failed, coverage }
116
+ ```
117
+
118
+ ### Package Dependencies
119
+
120
+ ```mermaid
121
+ graph BT
122
+ subgraph "Test Packages"
123
+ ClientVitest[client-vitest]
124
+ ClientTest[client-test]
125
+ end
126
+
127
+ subgraph "Execution"
128
+ Shell[client-shell]
129
+ end
130
+
131
+ subgraph "Core"
132
+ Client[client]
133
+ end
134
+
135
+ subgraph "External"
136
+ Vitest[vitest]
137
+ end
138
+
139
+ ClientVitest --> Shell
140
+ ClientVitest --> Client
141
+ ClientTest --> Shell
142
+ ClientTest --> Client
143
+ Shell --> Client
144
+ ClientVitest -.->|executes| Vitest
145
+ ```
146
+
147
+ ---
148
+
149
+ ## Quick Start
150
+
151
+ ```typescript
152
+ import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@mark1russell7/client";
153
+ import "@mark1russell7/client-vitest"; // registers its procedures
154
+
155
+ const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
156
+
157
+ // Run all tests
158
+ const result = await client.exec(["vitest", "run"], {
159
+ cwd: "/path/to/project",
160
+ });
161
+
162
+ console.log(`Passed: ${result.passed}, Failed: ${result.failed}`);
163
+
164
+ // Run with coverage
165
+ const coverage = await client.exec(["vitest", "run"], {
166
+ coverage: true,
167
+ });
168
+
169
+ if (coverage.coverage) {
170
+ console.log(`Line coverage: ${coverage.coverage.lines}%`);
171
+ }
172
+ ```
173
+
174
+ ---
175
+
176
+ ## API Reference
177
+
178
+ ### Procedures Summary
179
+
180
+ | Path | Description |
181
+ |------|-------------|
182
+ | `vitest.run` | Run tests once |
183
+ | `vitest.coverage` | Run tests once with coverage, and check a minimum line coverage |
184
+ | `vitest.watch` | Start watch mode |
185
+ | `vitest.stop` | Stop a watch process (all of them without an id) |
186
+ | `vitest.list` | List the watch processes of this host |
187
+
188
+ `vitest.watch`, `vitest.stop` and `vitest.list` are not MCP tools. A watch process is a record of the process registry of `client-shell`, and it ends with the host.
189
+
190
+ ---
191
+
192
+ ### vitest.run
193
+
194
+ Run Vitest tests with configurable options.
195
+
196
+ ```typescript
197
+ interface VitestRunInput {
198
+ cwd?: string; // Working directory
199
+ include?: string[]; // Include patterns
200
+ exclude?: string[]; // Exclude patterns
201
+ watch?: boolean; // Watch mode
202
+ coverage?: boolean; // Enable coverage
203
+ reporter?: "default" | "verbose" | "json" | "junit";
204
+ passWithNoTests?: boolean; // Pass if no tests found
205
+ }
206
+
207
+ interface VitestRunOutput {
208
+ success: boolean;
209
+ passed: number;
210
+ failed: number;
211
+ skipped: number;
212
+ duration: number; // ms
213
+ coverage?: {
214
+ lines: number;
215
+ branches: number;
216
+ functions: number;
217
+ statements: number;
218
+ };
219
+ }
220
+ ```
221
+
222
+ **Options:**
223
+
224
+ | Option | Type | Default | Description |
225
+ |--------|------|---------|-------------|
226
+ | `cwd` | string | "." | Working directory |
227
+ | `include` | string[] | - | Glob patterns to include |
228
+ | `exclude` | string[] | - | Glob patterns to exclude |
229
+ | `coverage` | boolean | false | Enable coverage reporting |
230
+ | `reporter` | string | "default" | Output format |
231
+ | `passWithNoTests` | boolean | false | Don't fail if no tests |
232
+
233
+ **Example:**
234
+ ```typescript
235
+ // Run specific tests
236
+ const result = await client.exec(["vitest", "run"], {
237
+ include: ["src/**/*.test.ts"],
238
+ exclude: ["**/*.e2e.test.ts"],
239
+ reporter: "verbose",
240
+ });
241
+
242
+ // Run with coverage threshold check
243
+ const coverage = await client.exec(["vitest", "run"], {
244
+ coverage: true,
245
+ });
246
+
247
+ if (coverage.coverage && coverage.coverage.lines < 80) {
248
+ console.warn("Coverage below 80%!");
249
+ process.exit(1);
250
+ }
251
+ ```
252
+
253
+ ---
254
+
255
+ ### vitest.watch
256
+
257
+ Start Vitest in watch mode for continuous testing.
258
+
259
+ ```typescript
260
+ interface VitestWatchInput {
261
+ cwd?: string; // Working directory
262
+ include?: string[]; // Include patterns
263
+ }
264
+
265
+ interface VitestWatchOutput {
266
+ id: string; // The id for vitest.stop
267
+ pid: number; // Process ID
268
+ status: "started" | "stopped";
269
+ }
270
+ ```
271
+
272
+ **Example:**
273
+ ```typescript
274
+ // Start watch mode
275
+ const { id } = await client.exec(["vitest", "watch"], {
276
+ include: ["src/**/*.test.ts"],
277
+ });
278
+
279
+ // The end of the output of each watch process
280
+ const { processes } = await client.exec(["vitest", "list"], { output: true });
281
+
282
+ // Stop the watch process and the processes that it started
283
+ await client.exec(["vitest", "stop"], { id });
284
+ ```
285
+
286
+ ---
287
+
288
+ ## Coverage Reporting
289
+
290
+ ### Enabling Coverage
291
+
292
+ ```typescript
293
+ const result = await client.exec(["vitest", "run"], {
294
+ coverage: true,
295
+ });
296
+ ```
297
+
298
+ ### Coverage Output Format
299
+
300
+ ```typescript
301
+ {
302
+ success: true,
303
+ passed: 42,
304
+ failed: 0,
305
+ skipped: 2,
306
+ duration: 5432,
307
+ coverage: {
308
+ lines: 87.5, // Percentage of lines covered
309
+ branches: 72.3, // Percentage of branches covered
310
+ functions: 91.2, // Percentage of functions covered
311
+ statements: 86.8 // Percentage of statements covered
312
+ }
313
+ }
314
+ ```
315
+
316
+ ### Coverage Visualization
317
+
318
+ ```mermaid
319
+ graph LR
320
+ subgraph "Coverage Metrics"
321
+ Lines[Lines: 87.5%]
322
+ Branches[Branches: 72.3%]
323
+ Functions[Functions: 91.2%]
324
+ Statements[Statements: 86.8%]
325
+ end
326
+
327
+ subgraph "Thresholds"
328
+ Good[">= 80%: Good"]
329
+ Warning["60-80%: Warning"]
330
+ Bad["< 60%: Needs work"]
331
+ end
332
+
333
+ Lines --> Good
334
+ Functions --> Good
335
+ Statements --> Good
336
+ Branches --> Warning
337
+ ```
338
+
339
+ ---
340
+
341
+ ## CLI Usage
342
+
343
+ ```bash
344
+ # Run tests via mark CLI
345
+ mark vitest run
346
+
347
+ # Run with coverage
348
+ mark vitest run --coverage
349
+
350
+ # Run specific patterns
351
+ mark vitest run --include "src/**/*.unit.test.ts"
352
+
353
+ # Multiple patterns
354
+ mark vitest run --include "src/**/*.test.ts" --exclude "**/*.e2e.test.ts"
355
+
356
+ # Start watch mode
357
+ mark vitest watch
358
+
359
+ # Verbose output
360
+ mark vitest run --reporter verbose
361
+ ```
362
+
363
+ ---
364
+
365
+ ## Integration
366
+
367
+ ### With MCP (Claude)
368
+
369
+ When using the MCP server, Claude can:
370
+ - Run tests: "Run the tests for this project"
371
+ - Check coverage: "Run tests with coverage and tell me the results"
372
+ - Watch mode: "Start test watch mode"
373
+
374
+ ### With DAG Traverse
375
+
376
+ ```typescript
377
+ // Run tests across all packages in dependency order
378
+ await client.exec(["dag", "traverse"], {
379
+ visit: ["vitest", "run"],
380
+ concurrency: 2,
381
+ });
382
+ ```
383
+
384
+ ### With CI/CD
385
+
386
+ ```typescript
387
+ // CI script example
388
+ const result = await client.exec(["vitest", "run"], {
389
+ coverage: true,
390
+ reporter: "junit",
391
+ });
392
+
393
+ if (!result.success) {
394
+ process.exit(1);
395
+ }
396
+
397
+ if (result.coverage && result.coverage.lines < 80) {
398
+ console.error("Coverage threshold not met");
399
+ process.exit(1);
400
+ }
401
+ ```
402
+
403
+ ### With Other Test Packages
404
+
405
+ ```mermaid
406
+ graph TB
407
+ subgraph "Generic Testing"
408
+ Test[client-test<br/>test.run, test.coverage]
409
+ end
410
+
411
+ subgraph "Framework-Specific"
412
+ Vitest[client-vitest<br/>vitest.run, vitest.watch]
413
+ Jest[client-jest<br/>future]
414
+ Mocha[client-mocha<br/>future]
415
+ end
416
+
417
+ subgraph "Execution"
418
+ Shell[client-shell]
419
+ end
420
+
421
+ Test --> Shell
422
+ Vitest --> Shell
423
+ Jest --> Shell
424
+ Mocha --> Shell
425
+ ```
426
+
427
+ ---
428
+
429
+ ## Requirements
430
+
431
+ - **Node.js** >= 22
432
+ - **Vitest** >= 3.0 (peer dependency)
433
+ - **Dependencies:**
434
+ - `@mark1russell7/client`
435
+ - `@mark1russell7/client-shell`
436
+
437
+ ---
438
+
439
+ ## License
440
+
441
+ MIT