@boolesai/tspec-cli 1.1.0 → 1.3.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.
- package/README.md +291 -25
- package/dist/index.js +492 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/types/commands/plugin-install.d.ts +24 -0
- package/types/commands/plugin-list.d.ts +39 -0
- package/types/commands/run.d.ts +2 -0
- package/types/utils/files.d.ts +43 -4
package/README.md
CHANGED
|
@@ -17,11 +17,125 @@ Or run directly with npx:
|
|
|
17
17
|
npx @boolesai/tspec-cli <command>
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## Plugin Installation
|
|
21
|
+
|
|
22
|
+
TSpec uses a plugin architecture to support different protocols. Plugins can be installed automatically or manually.
|
|
23
|
+
|
|
24
|
+
### Installing Plugins via CLI
|
|
25
|
+
|
|
26
|
+
The easiest way to install plugins is using the `plugin:install` command:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Install HTTP/HTTPS protocol plugin
|
|
30
|
+
tspec plugin:install @tspec/http
|
|
31
|
+
|
|
32
|
+
# Install Web browser UI testing plugin
|
|
33
|
+
tspec plugin:install @tspec/web
|
|
34
|
+
|
|
35
|
+
# Install and add to global config
|
|
36
|
+
tspec plugin:install @tspec/http --global
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Manual Installation
|
|
40
|
+
|
|
41
|
+
You can also install plugins manually as npm packages:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Install HTTP/HTTPS protocol plugin
|
|
45
|
+
npm install -D @tspec/http
|
|
46
|
+
|
|
47
|
+
# Install Web browser UI testing plugin
|
|
48
|
+
npm install -D @tspec/web
|
|
49
|
+
|
|
50
|
+
# Install multiple plugins at once
|
|
51
|
+
npm install -D @tspec/http @tspec/web
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Plugin Configuration
|
|
55
|
+
|
|
56
|
+
TSpec uses JSON configuration files. Create a `tspec.config.json` file in your project root:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"plugins": [
|
|
61
|
+
"@tspec/http",
|
|
62
|
+
"@tspec/web"
|
|
63
|
+
],
|
|
64
|
+
"pluginOptions": {
|
|
65
|
+
"@tspec/http": {
|
|
66
|
+
"timeout": 30000,
|
|
67
|
+
"followRedirects": true,
|
|
68
|
+
"maxRedirects": 5
|
|
69
|
+
},
|
|
70
|
+
"@tspec/web": {
|
|
71
|
+
"headless": true,
|
|
72
|
+
"timeout": 30000,
|
|
73
|
+
"slowMo": 0
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Configuration Locations
|
|
80
|
+
|
|
81
|
+
TSpec supports dual configuration with local taking precedence:
|
|
82
|
+
|
|
83
|
+
| Location | Path | Priority |
|
|
84
|
+
|----------|------|----------|
|
|
85
|
+
| Local | `./tspec.config.json` (searched upward) | Higher |
|
|
86
|
+
| Global | `~/.tspec/tspec.config.json` | Lower |
|
|
87
|
+
|
|
88
|
+
When both configs exist, they are merged with local values overriding global ones.
|
|
89
|
+
|
|
90
|
+
#### Auto-Installation
|
|
91
|
+
|
|
92
|
+
When running `tspec run`, missing plugins in your config are automatically installed to `~/.tspec/plugins/`. Use `--no-auto-install` to disable this behavior.
|
|
93
|
+
|
|
94
|
+
### Available Official Plugins
|
|
95
|
+
|
|
96
|
+
| Plugin | Protocol | Description | Package |
|
|
97
|
+
|--------|----------|-------------|----------|
|
|
98
|
+
| HTTP/HTTPS | `http`, `https` | REST API testing with axios | `@tspec/http` |
|
|
99
|
+
| Web UI | `web` | Browser testing with Puppeteer | `@tspec/web` |
|
|
100
|
+
|
|
101
|
+
### Using Plugins
|
|
102
|
+
|
|
103
|
+
Once installed and configured, plugins are automatically loaded when running tests:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Run HTTP tests
|
|
107
|
+
tspec run tests/**/*.http.tcase
|
|
108
|
+
|
|
109
|
+
# Run Web UI tests
|
|
110
|
+
tspec run tests/**/*.web.tcase
|
|
111
|
+
|
|
112
|
+
# List loaded plugins and supported protocols
|
|
113
|
+
tspec list
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Custom Plugins
|
|
117
|
+
|
|
118
|
+
You can also install custom third-party plugins or create your own:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Install custom plugin from npm
|
|
122
|
+
tspec plugin:install my-custom-tspec-plugin
|
|
123
|
+
|
|
124
|
+
# Or use a local plugin path in tspec.config.json:
|
|
125
|
+
{
|
|
126
|
+
"plugins": [
|
|
127
|
+
"./plugins/my-custom-protocol"
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
For plugin development details, see the [Plugin Development Guide](../plugins/DEVELOPMENT.md).
|
|
133
|
+
|
|
20
134
|
## Commands
|
|
21
135
|
|
|
22
136
|
### `tspec validate`
|
|
23
137
|
|
|
24
|
-
Validate `.
|
|
138
|
+
Validate `.tcase` files for schema correctness.
|
|
25
139
|
|
|
26
140
|
```bash
|
|
27
141
|
tspec validate <files...> [options]
|
|
@@ -34,13 +148,13 @@ tspec validate <files...> [options]
|
|
|
34
148
|
**Examples:**
|
|
35
149
|
```bash
|
|
36
150
|
# Validate a single file
|
|
37
|
-
tspec validate tests/login.http.
|
|
151
|
+
tspec validate tests/login.http.tcase
|
|
38
152
|
|
|
39
153
|
# Validate multiple files with glob pattern
|
|
40
|
-
tspec validate "tests/**/*.
|
|
154
|
+
tspec validate "tests/**/*.tcase"
|
|
41
155
|
|
|
42
156
|
# JSON output for CI/CD
|
|
43
|
-
tspec validate tests/*.
|
|
157
|
+
tspec validate tests/*.tcase --output json
|
|
44
158
|
```
|
|
45
159
|
|
|
46
160
|
### `tspec run`
|
|
@@ -59,29 +173,31 @@ tspec run <files...> [options]
|
|
|
59
173
|
- `-v, --verbose` - Verbose output
|
|
60
174
|
- `-q, --quiet` - Only output summary
|
|
61
175
|
- `--fail-fast` - Stop on first failure
|
|
176
|
+
- `--config <path>` - Path to tspec.config.json
|
|
177
|
+
- `--no-auto-install` - Skip automatic plugin installation
|
|
62
178
|
|
|
63
179
|
**Examples:**
|
|
64
180
|
```bash
|
|
65
181
|
# Run tests with default settings
|
|
66
|
-
tspec run tests/*.http.
|
|
182
|
+
tspec run tests/*.http.tcase
|
|
67
183
|
|
|
68
184
|
# Run with environment variables
|
|
69
|
-
tspec run tests/*.
|
|
185
|
+
tspec run tests/*.tcase -e API_HOST=api.example.com -e API_KEY=secret
|
|
70
186
|
|
|
71
187
|
# Run with parameters
|
|
72
|
-
tspec run tests/*.
|
|
188
|
+
tspec run tests/*.tcase -p username=testuser -p timeout=5000
|
|
73
189
|
|
|
74
190
|
# Run with higher concurrency
|
|
75
|
-
tspec run tests/*.
|
|
191
|
+
tspec run tests/*.tcase -c 10
|
|
76
192
|
|
|
77
193
|
# Verbose output for debugging
|
|
78
|
-
tspec run tests/*.
|
|
194
|
+
tspec run tests/*.tcase -v
|
|
79
195
|
|
|
80
196
|
# JSON output for CI/CD
|
|
81
|
-
tspec run tests/*.
|
|
197
|
+
tspec run tests/*.tcase --output json
|
|
82
198
|
|
|
83
199
|
# Stop on first failure
|
|
84
|
-
tspec run tests/*.
|
|
200
|
+
tspec run tests/*.tcase --fail-fast
|
|
85
201
|
```
|
|
86
202
|
|
|
87
203
|
### `tspec parse`
|
|
@@ -102,13 +218,13 @@ tspec parse <files...> [options]
|
|
|
102
218
|
**Examples:**
|
|
103
219
|
```bash
|
|
104
220
|
# Parse and display test cases
|
|
105
|
-
tspec parse tests/login.http.
|
|
221
|
+
tspec parse tests/login.http.tcase
|
|
106
222
|
|
|
107
223
|
# JSON output for inspection
|
|
108
|
-
tspec parse tests/*.
|
|
224
|
+
tspec parse tests/*.tcase --output json
|
|
109
225
|
|
|
110
226
|
# With variable substitution
|
|
111
|
-
tspec parse tests/*.
|
|
227
|
+
tspec parse tests/*.tcase -e API_HOST=localhost
|
|
112
228
|
```
|
|
113
229
|
|
|
114
230
|
### `tspec list`
|
|
@@ -131,6 +247,62 @@ tspec list
|
|
|
131
247
|
tspec list --output json
|
|
132
248
|
```
|
|
133
249
|
|
|
250
|
+
### `tspec plugin:install`
|
|
251
|
+
|
|
252
|
+
Install a TSpec plugin and add it to configuration.
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
tspec plugin:install <plugin> [options]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Options:**
|
|
259
|
+
- `-o, --output <format>` - Output format: `json`, `text` (default: `text`)
|
|
260
|
+
- `-g, --global` - Add plugin to global config (`~/.tspec/tspec.config.json`)
|
|
261
|
+
- `-c, --config <path>` - Path to specific config file to update
|
|
262
|
+
|
|
263
|
+
**Examples:**
|
|
264
|
+
```bash
|
|
265
|
+
# Install plugin (adds to local config if exists, otherwise global)
|
|
266
|
+
tspec plugin:install @tspec/http
|
|
267
|
+
|
|
268
|
+
# Install and add to global config
|
|
269
|
+
tspec plugin:install @tspec/web --global
|
|
270
|
+
|
|
271
|
+
# Install and add to specific config file
|
|
272
|
+
tspec plugin:install @tspec/http --config ./tspec.config.json
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### `tspec plugin:list`
|
|
276
|
+
|
|
277
|
+
List all installed TSpec plugins and configuration sources.
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
tspec plugin:list [options]
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Alias:** `tspec plugins`
|
|
284
|
+
|
|
285
|
+
**Options:**
|
|
286
|
+
- `-o, --output <format>` - Output format: `json`, `text` (default: `text`)
|
|
287
|
+
- `-v, --verbose` - Show detailed plugin information
|
|
288
|
+
- `--health` - Run health checks on all plugins
|
|
289
|
+
- `-c, --config <path>` - Path to tspec.config.json
|
|
290
|
+
|
|
291
|
+
**Examples:**
|
|
292
|
+
```bash
|
|
293
|
+
# List installed plugins
|
|
294
|
+
tspec plugin:list
|
|
295
|
+
|
|
296
|
+
# Show detailed information
|
|
297
|
+
tspec plugin:list --verbose
|
|
298
|
+
|
|
299
|
+
# Check plugin health status
|
|
300
|
+
tspec plugin:list --health
|
|
301
|
+
|
|
302
|
+
# JSON output
|
|
303
|
+
tspec plugin:list --output json
|
|
304
|
+
```
|
|
305
|
+
|
|
134
306
|
### `tspec mcp`
|
|
135
307
|
|
|
136
308
|
Start MCP (Model Context Protocol) server for AI tool integration.
|
|
@@ -143,23 +315,36 @@ This starts an MCP server over stdio that exposes TSpec commands as tools for AI
|
|
|
143
315
|
|
|
144
316
|
## MCP Integration
|
|
145
317
|
|
|
146
|
-
TSpec CLI can run as an MCP server, exposing all commands as tools for AI assistants.
|
|
318
|
+
TSpec CLI can run as an MCP (Model Context Protocol) server, exposing all commands as tools for AI assistants. This enables AI assistants like Claude to execute TSpec commands directly through the MCP protocol.
|
|
319
|
+
|
|
320
|
+
### Overview
|
|
321
|
+
|
|
322
|
+
The MCP server runs over stdio, providing a standardized interface for AI tools to:
|
|
323
|
+
- Execute test cases with customizable parameters
|
|
324
|
+
- Validate test case files for schema correctness
|
|
325
|
+
- Parse test specifications without execution
|
|
326
|
+
- Query supported protocols and configurations
|
|
147
327
|
|
|
148
328
|
### Available Tools
|
|
149
329
|
|
|
150
330
|
| Tool | Description |
|
|
151
331
|
|------|-------------|
|
|
152
332
|
| `tspec_run` | Execute test cases and report results |
|
|
153
|
-
| `tspec_validate` | Validate .
|
|
333
|
+
| `tspec_validate` | Validate .tcase files for schema correctness |
|
|
154
334
|
| `tspec_parse` | Parse and display test case information |
|
|
155
335
|
| `tspec_list` | List supported protocols |
|
|
156
336
|
|
|
157
|
-
###
|
|
337
|
+
### Configuration
|
|
338
|
+
|
|
339
|
+
#### Claude Desktop
|
|
158
340
|
|
|
159
341
|
Add the following to your Claude Desktop configuration file:
|
|
160
342
|
|
|
161
343
|
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
162
344
|
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
345
|
+
**Linux:** `~/.config/Claude/claude_desktop_config.json`
|
|
346
|
+
|
|
347
|
+
**Option 1: Using npx (recommended for always getting the latest version):**
|
|
163
348
|
|
|
164
349
|
```json
|
|
165
350
|
{
|
|
@@ -172,7 +357,7 @@ Add the following to your Claude Desktop configuration file:
|
|
|
172
357
|
}
|
|
173
358
|
```
|
|
174
359
|
|
|
175
|
-
|
|
360
|
+
**Option 2: Using global installation:**
|
|
176
361
|
|
|
177
362
|
```json
|
|
178
363
|
{
|
|
@@ -185,15 +370,56 @@ Or if installed globally:
|
|
|
185
370
|
}
|
|
186
371
|
```
|
|
187
372
|
|
|
373
|
+
**Option 3: Using absolute path (for development or specific versions):**
|
|
374
|
+
|
|
375
|
+
```json
|
|
376
|
+
{
|
|
377
|
+
"mcpServers": {
|
|
378
|
+
"tspec": {
|
|
379
|
+
"command": "/path/to/tspec/cli/bin/tspec.js",
|
|
380
|
+
"args": ["mcp"]
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
#### Other MCP Clients
|
|
387
|
+
|
|
388
|
+
For other MCP-compatible clients, start the server with:
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
tspec mcp
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
The server will communicate via stdio, waiting for JSON-RPC 2.0 formatted requests.
|
|
395
|
+
|
|
396
|
+
### Server Behavior
|
|
397
|
+
|
|
398
|
+
- **Transport:** stdio (reads from stdin, writes to stdout)
|
|
399
|
+
- **Protocol:** JSON-RPC 2.0 over MCP
|
|
400
|
+
- **Lifecycle:** Runs indefinitely until explicitly terminated (Ctrl+C or SIGTERM)
|
|
401
|
+
- **Logging:** Error logs are written to stderr to avoid polluting stdio transport
|
|
402
|
+
|
|
188
403
|
### Tool Parameters
|
|
189
404
|
|
|
190
405
|
#### tspec_run
|
|
191
406
|
|
|
407
|
+
Execute test cases with optional configuration.
|
|
408
|
+
|
|
409
|
+
**Parameters:**
|
|
410
|
+
- `files` (required): Array of file paths or glob patterns
|
|
411
|
+
- `concurrency` (optional): Maximum concurrent test execution (default: 5)
|
|
412
|
+
- `env` (optional): Environment variables as key-value object
|
|
413
|
+
- `params` (optional): Test parameters as key-value object
|
|
414
|
+
- `failFast` (optional): Stop on first failure (default: false)
|
|
415
|
+
- `output` (optional): Output format - "json" or "text" (default: "text")
|
|
416
|
+
|
|
417
|
+
**Example:**
|
|
192
418
|
```json
|
|
193
419
|
{
|
|
194
|
-
"files": ["tests/*.
|
|
420
|
+
"files": ["tests/*.tcase"],
|
|
195
421
|
"concurrency": 5,
|
|
196
|
-
"env": { "API_HOST": "localhost" },
|
|
422
|
+
"env": { "API_HOST": "localhost", "API_PORT": "8080" },
|
|
197
423
|
"params": { "timeout": "5000" },
|
|
198
424
|
"failFast": false,
|
|
199
425
|
"output": "text"
|
|
@@ -202,18 +428,35 @@ Or if installed globally:
|
|
|
202
428
|
|
|
203
429
|
#### tspec_validate
|
|
204
430
|
|
|
431
|
+
Validate test case files for schema correctness.
|
|
432
|
+
|
|
433
|
+
**Parameters:**
|
|
434
|
+
- `files` (required): Array of file paths or glob patterns
|
|
435
|
+
- `output` (optional): Output format - "json" or "text" (default: "text")
|
|
436
|
+
|
|
437
|
+
**Example:**
|
|
205
438
|
```json
|
|
206
439
|
{
|
|
207
|
-
"files": ["tests/*.
|
|
440
|
+
"files": ["tests/*.tcase"],
|
|
208
441
|
"output": "text"
|
|
209
442
|
}
|
|
210
443
|
```
|
|
211
444
|
|
|
212
445
|
#### tspec_parse
|
|
213
446
|
|
|
447
|
+
Parse test case files without execution.
|
|
448
|
+
|
|
449
|
+
**Parameters:**
|
|
450
|
+
- `files` (required): Array of file paths or glob patterns
|
|
451
|
+
- `env` (optional): Environment variables for variable substitution
|
|
452
|
+
- `params` (optional): Parameters for variable substitution
|
|
453
|
+
- `verbose` (optional): Show detailed information (default: false)
|
|
454
|
+
- `output` (optional): Output format - "json" or "text" (default: "text")
|
|
455
|
+
|
|
456
|
+
**Example:**
|
|
214
457
|
```json
|
|
215
458
|
{
|
|
216
|
-
"files": ["tests/*.
|
|
459
|
+
"files": ["tests/*.tcase"],
|
|
217
460
|
"env": { "API_HOST": "localhost" },
|
|
218
461
|
"params": { "timeout": "5000" },
|
|
219
462
|
"verbose": true,
|
|
@@ -223,12 +466,35 @@ Or if installed globally:
|
|
|
223
466
|
|
|
224
467
|
#### tspec_list
|
|
225
468
|
|
|
469
|
+
List supported protocols and configuration.
|
|
470
|
+
|
|
471
|
+
**Parameters:**
|
|
472
|
+
- `output` (optional): Output format - "json" or "text" (default: "text")
|
|
473
|
+
|
|
474
|
+
**Example:**
|
|
226
475
|
```json
|
|
227
476
|
{
|
|
228
477
|
"output": "text"
|
|
229
478
|
}
|
|
230
479
|
```
|
|
231
480
|
|
|
481
|
+
### Troubleshooting
|
|
482
|
+
|
|
483
|
+
**Server doesn't appear in Claude Desktop:**
|
|
484
|
+
- Verify the configuration file path is correct for your OS
|
|
485
|
+
- Check JSON syntax is valid (use a JSON validator)
|
|
486
|
+
- Restart Claude Desktop after configuration changes
|
|
487
|
+
- Check Claude Desktop logs for connection errors
|
|
488
|
+
|
|
489
|
+
**Server hangs or doesn't respond:**
|
|
490
|
+
- Ensure Node.js >= 18.0.0 is installed
|
|
491
|
+
- Verify `@boolesai/tspec-cli` is accessible (try running `tspec --version`)
|
|
492
|
+
- Check stderr output for error messages
|
|
493
|
+
|
|
494
|
+
**Permission errors:**
|
|
495
|
+
- Ensure the tspec executable has proper permissions
|
|
496
|
+
- For global installation, verify npm global bin directory is in PATH
|
|
497
|
+
|
|
232
498
|
## Exit Codes
|
|
233
499
|
|
|
234
500
|
| Code | Description |
|
|
@@ -244,10 +510,10 @@ Or if installed globally:
|
|
|
244
510
|
```yaml
|
|
245
511
|
- name: Run TSpec tests
|
|
246
512
|
run: |
|
|
247
|
-
npx @boolesai/tspec-cli run tests/*.
|
|
513
|
+
npx @boolesai/tspec-cli run tests/*.tcase --output json > results.json
|
|
248
514
|
|
|
249
515
|
- name: Validate TSpec files
|
|
250
|
-
run: npx @boolesai/tspec-cli validate tests/*.
|
|
516
|
+
run: npx @boolesai/tspec-cli validate tests/*.tcase
|
|
251
517
|
```
|
|
252
518
|
|
|
253
519
|
### GitLab CI
|
|
@@ -255,7 +521,7 @@ Or if installed globally:
|
|
|
255
521
|
```yaml
|
|
256
522
|
test:
|
|
257
523
|
script:
|
|
258
|
-
- npx @boolesai/tspec-cli run tests/*.
|
|
524
|
+
- npx @boolesai/tspec-cli run tests/*.tcase --output json
|
|
259
525
|
artifacts:
|
|
260
526
|
reports:
|
|
261
527
|
junit: results.json
|