@democratize-quality/mcp-server 1.2.0 → 1.2.1

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/cli.js +248 -0
  2. package/package.json +7 -5
  3. package/src/chatmodes//360/237/214/220 api-generator.chatmode.md" +409 -0
  4. package/src/chatmodes//360/237/214/220 api-healer.chatmode.md" +494 -0
  5. package/src/chatmodes//360/237/214/220 api-planner.chatmode.md" +954 -0
  6. package/src/config/environments/api-only.js +72 -0
  7. package/src/config/environments/development.js +73 -0
  8. package/src/config/environments/production.js +88 -0
  9. package/src/config/index.js +360 -0
  10. package/src/config/server.js +60 -0
  11. package/src/config/tools/api.js +86 -0
  12. package/src/config/tools/browser.js +109 -0
  13. package/src/config/tools/default.js +51 -0
  14. package/src/docs/Agent_README.md +310 -0
  15. package/src/docs/QUICK_REFERENCE.md +111 -0
  16. package/src/server.ts +234 -0
  17. package/src/services/browserService.js +344 -0
  18. package/src/skills/api-planning/SKILL.md +224 -0
  19. package/src/skills/test-execution/SKILL.md +777 -0
  20. package/src/skills/test-generation/SKILL.md +309 -0
  21. package/src/skills/test-healing/SKILL.md +405 -0
  22. package/src/tools/api/api-generator.js +1884 -0
  23. package/src/tools/api/api-healer.js +636 -0
  24. package/src/tools/api/api-planner.js +2617 -0
  25. package/src/tools/api/api-project-setup.js +332 -0
  26. package/src/tools/api/api-request.js +660 -0
  27. package/src/tools/api/api-session-report.js +1297 -0
  28. package/src/tools/api/api-session-status.js +414 -0
  29. package/src/tools/api/prompts/README.md +293 -0
  30. package/src/tools/api/prompts/generation-prompts.js +722 -0
  31. package/src/tools/api/prompts/healing-prompts.js +214 -0
  32. package/src/tools/api/prompts/index.js +44 -0
  33. package/src/tools/api/prompts/orchestrator.js +353 -0
  34. package/src/tools/api/prompts/validation-rules.js +358 -0
  35. package/src/tools/base/ToolBase.js +249 -0
  36. package/src/tools/base/ToolRegistry.js +288 -0
  37. package/src/tools/browser/advanced/browser-console.js +403 -0
  38. package/src/tools/browser/advanced/browser-dialog.js +338 -0
  39. package/src/tools/browser/advanced/browser-evaluate.js +356 -0
  40. package/src/tools/browser/advanced/browser-file.js +499 -0
  41. package/src/tools/browser/advanced/browser-keyboard.js +362 -0
  42. package/src/tools/browser/advanced/browser-mouse.js +351 -0
  43. package/src/tools/browser/advanced/browser-network.js +440 -0
  44. package/src/tools/browser/advanced/browser-pdf.js +426 -0
  45. package/src/tools/browser/advanced/browser-tabs.js +516 -0
  46. package/src/tools/browser/advanced/browser-wait.js +397 -0
  47. package/src/tools/browser/click.js +187 -0
  48. package/src/tools/browser/close.js +79 -0
  49. package/src/tools/browser/dom.js +89 -0
  50. package/src/tools/browser/launch.js +86 -0
  51. package/src/tools/browser/navigate.js +289 -0
  52. package/src/tools/browser/screenshot.js +370 -0
  53. package/src/tools/browser/type.js +193 -0
  54. package/src/tools/index.js +114 -0
  55. package/src/utils/agentInstaller.js +437 -0
  56. package/src/utils/browserHelpers.js +102 -0
@@ -0,0 +1,777 @@
1
+ ---
2
+ name: test-execution
3
+ description: Execute API tests directly from test plans using actual API requests. Run tests section-by-section or entirely, validate responses, chain requests, and generate comprehensive HTML reports. Use when user wants to run tests, execute API calls from test plan, validate endpoints, or create test execution reports.
4
+ ---
5
+
6
+ # API Test Execution Skill
7
+
8
+ Use this skill to execute API tests directly from test plans without writing code. Run comprehensive test sequences, validate responses, and generate visual HTML reports.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - User has a test plan and wants to execute tests immediately
13
+ - User mentions running tests without generating code
14
+ - User needs to validate API endpoints from test plan
15
+ - User wants to execute specific sections of a test plan
16
+ - User requests test execution reports or validation results
17
+ - User needs quick API testing without setup
18
+
19
+ ## Core Workflow
20
+
21
+ ### Step 1: Load Test Plan
22
+
23
+ **Read the test plan file** that was generated by `api_planner`:
24
+
25
+ ```javascript
26
+ // User provides test plan path
27
+ const testPlanPath = "./api-test-reports/api-test-plan.md";
28
+
29
+ // Read the test plan content
30
+ const testPlanContent = await readFile(testPlanPath);
31
+
32
+ // Parse sections using markdown headers (##)
33
+ // Each section represents a testable API endpoint or feature
34
+ ```
35
+
36
+ ### Step 2: Select Section or Full Execution
37
+
38
+ **Ask user what to execute** (if not specified):
39
+
40
+ ```javascript
41
+ // Parse test plan sections
42
+ const sections = parseTestPlanSections(testPlanContent);
43
+
44
+ // User can specify:
45
+ // - "Execute section 1" or "Run tests for GET /api/v1/Books"
46
+ // - "Execute all sections" or "Run entire test plan"
47
+ // - "Run sections 1, 3, and 5"
48
+
49
+ // Section structure example:
50
+ // ## 1. GET /api/v1/Books - Retrieve all books
51
+ // - Endpoint: GET /api/v1/Books
52
+ // - Expected Status: 200
53
+ // - Sample Request: [details]
54
+ // - Expected Response: [structure]
55
+ ```
56
+
57
+ **Section Selection Examples:**
58
+ - Section number: "Execute section 1"
59
+ - Endpoint match: "Run tests for Books API"
60
+ - Multiple sections: "Execute sections 1, 2, and 4"
61
+ - Full plan: "Run all tests" or "Execute entire test plan"
62
+
63
+ ### Step 3: Parse Test Data from Section
64
+
65
+ **Extract test information** from the selected section(s):
66
+
67
+ ```javascript
68
+ // For each test section, extract:
69
+ const testData = {
70
+ method: "GET", // HTTP method
71
+ endpoint: "/api/v1/Books", // API endpoint
72
+ baseUrl: "https://api.example.com", // From test plan overview
73
+ expectedStatus: 200, // Expected HTTP status
74
+ headers: { // Authentication and headers
75
+ "Content-Type": "application/json",
76
+ "Authorization": "Bearer token-if-needed"
77
+ },
78
+ data: { // Request body (for POST/PUT/PATCH)
79
+ // Parsed from sample request in test plan
80
+ },
81
+ expectedResponse: { // Expected response structure
82
+ // Parsed from expected response section
83
+ }
84
+ }
85
+ ```
86
+
87
+ **Parsing Rules:**
88
+ - Extract HTTP method from section title or endpoint line
89
+ - Get endpoint URL from "Endpoint:" line
90
+ - Parse expected status from "Expected Status:" or "Status Code:" line
91
+ - Extract request body from "Sample Request:" or "Request Body:" section
92
+ - Get expected response from "Expected Response:" or "Response Structure:" section
93
+ - Identify authentication requirements from test plan
94
+
95
+ ### Step 3a: Smart Variable Extraction
96
+
97
+ When the user specifies a variable to extract (e.g., "extract token and userId"), **automatically resolve the correct path from the actual API response structure** — never rely on hardcoded field names. Use structural and semantic reasoning against the real response.
98
+
99
+ #### Rule 1: Semantic Field Matching
100
+
101
+ For the requested variable name, find the best matching field in the response using semantic proximity — not exact name matching. Apply these principles:
102
+
103
+ - **Partial name match**: A requested variable `userId` should match any field whose name contains `id` within an object whose name contains `user` — e.g., `user.id`, `account.id`, `customer.identifier`, `user.uuid` all qualify
104
+ - **Token/auth semantics**: A requested variable `token` should match any field whose name contains `token`, `jwt`, `key`, `secret`, or `credential` at any nesting level
105
+ - **ID semantics**: A requested variable `orderId` should match any field that looks like the primary identifier of the returned resource — typically a field named `id`, `uuid`, `reference`, or `<resourceName>Id` at the top level of the created object
106
+ - **When multiple candidates exist**, prefer the one closest to the top level and with the shortest path
107
+
108
+ #### Rule 2: Collection First-Item Extraction
109
+
110
+ When the user says "extract X from first result / first item / first product", do not assume the array key name. Instead:
111
+
112
+ 1. Inspect the response for **any key whose value is an array** with at least one element
113
+ 2. Take the first element (`[0]`)
114
+ 3. Within that element, find the field semantically matching the requested variable (apply Rule 1)
115
+
116
+ This works regardless of whether the collection is called `products`, `records`, `results`, `items`, `data`, `entries`, or anything else.
117
+
118
+ #### Rule 3: Response Envelope Unwrapping
119
+
120
+ Many APIs wrap the actual payload in an envelope. Before applying extraction rules, detect and unwrap one level automatically:
121
+
122
+ - **Single-key object**: `{ data: { ... } }` → unwrap `data`
123
+ - **Resource + metadata**: `{ items: [...], total: N, page: N }` → the array key is the payload
124
+ - **Auth envelope**: `{ user: { ... }, token: "..." }` → both `user` and `token` are top-level
125
+ - **Flat response**: `{ id: ..., name: ... }` → no unwrapping needed
126
+
127
+ If extraction still fails after unwrapping one level, try two levels deep before giving up.
128
+
129
+ #### Rule 4: Extraction Verification Guard
130
+
131
+ Before injecting any `{{variable}}` into a subsequent request, verify it resolved to a non-empty, non-null, non-undefined value. If verification fails:
132
+
133
+ 1. **Stop execution** — do not proceed to the next step
134
+ 2. **Report clearly**: state which variable failed, which step it came from, and show the actual response structure that was searched
135
+ 3. **Never produce broken URLs** — a URL like `/api/cart//items` (empty segment) is a silent failure and must be caught here
136
+
137
+ #### Rule 5: Type-Safe Substitution
138
+
139
+ When injecting extracted values into request bodies, preserve the original type from the response. Do not coerce types:
140
+
141
+ - A number in the response (`"price": 3.99`) must stay a number in the request body — not become a string `"3.99"`
142
+ - A boolean stays a boolean
143
+ - A string stays a string
144
+ - Arrays and objects are passed by reference as-is
145
+
146
+ ### Step 4: Execute Tests with Unique Session ID
147
+
148
+ **Create a unique session** and execute tests:
149
+
150
+ ```javascript
151
+ // Generate unique session ID
152
+ const sessionId = `test-execution-${Date.now()}`;
153
+ // Or use meaningful name: `test-execution-books-api-${Date.now()}`
154
+
155
+ // Execute each test in the section
156
+ for (const test of testsInSection) {
157
+ await tools.api_request({
158
+ sessionId: sessionId,
159
+ method: test.method,
160
+ url: `${test.baseUrl}${test.endpoint}`,
161
+ headers: test.headers,
162
+ data: test.data, // Only for POST/PUT/PATCH/DELETE
163
+ expect: {
164
+ status: test.expectedStatus,
165
+ // Optional: Add response validation
166
+ body: {
167
+ // Expected fields from test plan
168
+ }
169
+ },
170
+ extract: {
171
+ // Extract data for chained requests
172
+ // Example: { "bookId": "id" } to use in next request
173
+ }
174
+ })
175
+
176
+ console.log(`✅ Test passed: ${test.method} ${test.endpoint}`);
177
+ }
178
+ ```
179
+
180
+ **Request Chaining Example:**
181
+ ```javascript
182
+ // Step 1: Create a book and extract its ID
183
+ await tools.api_request({
184
+ sessionId: sessionId,
185
+ method: "POST",
186
+ url: "https://api.example.com/api/v1/Books",
187
+ data: {
188
+ title: "Test Book",
189
+ author: "Test Author"
190
+ },
191
+ expect: { status: 201 },
192
+ extract: { "bookId": "id" } // Save book ID for next request
193
+ })
194
+
195
+ // Step 2: Use extracted bookId in next request
196
+ await tools.api_request({
197
+ sessionId: sessionId,
198
+ method: "GET",
199
+ url: "https://api.example.com/api/v1/Books/{{bookId}}", // Uses extracted ID
200
+ expect: { status: 200 }
201
+ })
202
+
203
+ // Step 3: Update the book
204
+ await tools.api_request({
205
+ sessionId: sessionId,
206
+ method: "PUT",
207
+ url: "https://api.example.com/api/v1/Books/{{bookId}}",
208
+ data: {
209
+ title: "Updated Test Book",
210
+ author: "Test Author"
211
+ },
212
+ expect: { status: 200 }
213
+ })
214
+
215
+ // Step 4: Delete the book
216
+ await tools.api_request({
217
+ sessionId: sessionId,
218
+ method: "DELETE",
219
+ url: "https://api.example.com/api/v1/Books/{{bookId}}",
220
+ expect: { status: 204 }
221
+ })
222
+ ```
223
+
224
+ ### Step 5: Generate HTML Test Report
225
+
226
+ **After all tests execute**, generate comprehensive report:
227
+
228
+ ```javascript
229
+ await tools.api_session_report({
230
+ sessionId: sessionId,
231
+ outputPath: `./api-test-reports/${sessionId}-report.html`
232
+ })
233
+
234
+ // Optionally check final status
235
+ await tools.api_session_status({
236
+ sessionId: sessionId
237
+ })
238
+ ```
239
+
240
+ ## Execution Modes
241
+
242
+ ### Mode 1: Single Section Execution
243
+ ```javascript
244
+ // User: "Execute section 1 from the test plan"
245
+
246
+ // 1. Parse test plan
247
+ // 2. Extract section 1
248
+ // 3. Execute all tests in section 1
249
+ // 4. Generate report
250
+ ```
251
+
252
+ ### Mode 2: Multiple Sections Execution
253
+ ```javascript
254
+ // User: "Run tests for sections 1, 3, and 5"
255
+
256
+ // 1. Parse test plan
257
+ // 2. Extract sections 1, 3, and 5
258
+ // 3. Execute tests sequentially
259
+ // 4. Generate single comprehensive report
260
+ ```
261
+
262
+ ### Mode 3: Full Plan Execution
263
+ ```javascript
264
+ // User: "Execute all tests from the test plan"
265
+
266
+ // 1. Parse entire test plan
267
+ // 2. Execute all sections in order
268
+ // 3. Handle dependencies between tests
269
+ // 4. Generate comprehensive report with all results
270
+ ```
271
+
272
+ ### Mode 4: Filtered Execution
273
+ ```javascript
274
+ // User: "Run only GET and POST tests"
275
+
276
+ // 1. Parse test plan
277
+ // 2. Filter tests by HTTP method
278
+ // 3. Execute filtered tests
279
+ // 4. Generate filtered report
280
+ ```
281
+
282
+ ## Test Plan Parsing
283
+
284
+ ### Expected Test Plan Structure
285
+
286
+ ```markdown
287
+ # API Test Plan
288
+
289
+ ## Overview
290
+ - Base URL: https://api.example.com
291
+ - Authentication: Bearer Token
292
+ - API Version: v1
293
+
294
+ ## 1. GET /api/v1/Books - Retrieve all books
295
+
296
+ ### Endpoint
297
+ GET /api/v1/Books
298
+
299
+ ### Expected Status
300
+ 200 OK
301
+
302
+ ### Request Headers
303
+ - Content-Type: application/json
304
+ - Authorization: Bearer {{authToken}}
305
+
306
+ ### Sample Request
307
+ No request body required
308
+
309
+ ### Expected Response
310
+ ```json
311
+ [
312
+ {
313
+ "id": 1,
314
+ "title": "Book Title",
315
+ "author": "Author Name",
316
+ "isbn": "978-3-16-148410-0"
317
+ }
318
+ ]
319
+ ```
320
+
321
+ ### Validation Criteria
322
+ - Response is an array
323
+ - Each book has id, title, author fields
324
+ - Status code is 200
325
+
326
+ ## 2. POST /api/v1/Books - Create new book
327
+
328
+ ### Endpoint
329
+ POST /api/v1/Books
330
+
331
+ ### Expected Status
332
+ 201 Created
333
+
334
+ ### Request Headers
335
+ - Content-Type: application/json
336
+ - Authorization: Bearer {{authToken}}
337
+
338
+ ### Sample Request
339
+ ```json
340
+ {
341
+ "title": "New Book Title",
342
+ "author": "Author Name",
343
+ "isbn": "978-3-16-148410-0",
344
+ "publishedDate": "2026-02-15"
345
+ }
346
+ ```
347
+
348
+ ### Expected Response
349
+ ```json
350
+ {
351
+ "id": 42,
352
+ "title": "New Book Title",
353
+ "author": "Author Name",
354
+ "isbn": "978-3-16-148410-0",
355
+ "publishedDate": "2026-02-15",
356
+ "createdAt": "2026-02-15T10:30:00Z"
357
+ }
358
+ ```
359
+ ```
360
+
361
+ ### Parsing Strategy
362
+
363
+ **1. Extract Base Configuration:**
364
+ - Find "Base URL" or "API Base URL" in overview section
365
+ - Extract authentication method and headers
366
+ - Identify API version
367
+
368
+ **2. Identify Test Sections:**
369
+ - Look for markdown headers (##) that contain HTTP methods
370
+ - Pattern: `## N. METHOD /endpoint - Description`
371
+ - Examples: `## 1. GET /api/v1/Books`, `## 2. POST /api/v1/Users`
372
+
373
+ **3. Parse Section Content:**
374
+ - Extract endpoint URL
375
+ - Parse expected status code
376
+ - Find request headers
377
+ - Extract request body from code blocks
378
+ - Parse expected response from code blocks
379
+ - Identify validation criteria
380
+
381
+ **4. Handle Code Blocks:**
382
+ ```javascript
383
+ // JSON code blocks contain sample data
384
+ // Look for: ```json [content] ```
385
+ // Parse as JSON for request/response data
386
+ ```
387
+
388
+ ## Error Handling and Validation
389
+
390
+ ### Test Failure Handling
391
+
392
+ ```javascript
393
+ try {
394
+ await tools.api_request({
395
+ sessionId: sessionId,
396
+ method: "GET",
397
+ url: "https://api.example.com/api/v1/Books",
398
+ expect: { status: 200 }
399
+ })
400
+ console.log(`✅ Test passed: GET /api/v1/Books`);
401
+ } catch (error) {
402
+ console.error(`❌ Test failed: GET /api/v1/Books`);
403
+ console.error(` Error: ${error.message}`);
404
+ // Continue with remaining tests
405
+ }
406
+ ```
407
+
408
+ ### Validation Options
409
+
410
+ **Basic Status Validation:**
411
+ ```javascript
412
+ expect: { status: 200 }
413
+ ```
414
+
415
+ **Expected vs Actual Validation:**
416
+ ```javascript
417
+ expect: {
418
+ status: 200,
419
+ body: {
420
+ "items": expectedResponseFromTestPlan,
421
+ "count": "{{any}}" // Allow any value
422
+ }
423
+ }
424
+ ```
425
+
426
+ **Flexible Validation:**
427
+ ```javascript
428
+ expect: {
429
+ status: [200, 201], // Accept either status
430
+ body: {
431
+ "id": "{{number}}", // Must be a number
432
+ "title": "{{string}}", // Must be a string
433
+ "items": "{{array}}" // Must be an array
434
+ }
435
+ }
436
+ ```
437
+
438
+ ## Session Management
439
+
440
+ ### Tracking Test Execution
441
+
442
+ ```javascript
443
+ // Check test progress
444
+ await tools.api_session_status({
445
+ sessionId: sessionId
446
+ })
447
+
448
+ // Output includes:
449
+ // - Total requests made
450
+ // - Successful requests
451
+ // - Failed requests
452
+ // - Extracted variables
453
+ // - Request history
454
+ ```
455
+
456
+ ### Session Naming Conventions
457
+
458
+ **Descriptive Session IDs:**
459
+ ```javascript
460
+ // Format: test-execution-<feature>-<timestamp>
461
+ const sessionId = `test-execution-books-api-${Date.now()}`;
462
+ const sessionId = `test-execution-full-plan-${Date.now()}`;
463
+ const sessionId = `test-execution-section-1-${Date.now()}`;
464
+
465
+ // Benefits:
466
+ // - Easy to identify in reports
467
+ // - Helps organize multiple test runs
468
+ // - Clear audit trail
469
+ ```
470
+
471
+ ## Report Generation
472
+
473
+ ### HTML Report Features
474
+
475
+ The `api_session_report` tool generates:
476
+
477
+ - **Test Summary**
478
+ - Total tests executed
479
+ - Pass/fail statistics
480
+ - Execution duration
481
+ - Success rate percentage
482
+
483
+ - **Request Details**
484
+ - Each API call made
485
+ - Request method, URL, headers, body
486
+ - Response status, headers, body
487
+ - Timing information (response time)
488
+
489
+ - **Validation Results**
490
+ - Expected vs Actual comparisons
491
+ - Detailed failure messages
492
+ - Status code validation
493
+ - Response body validation
494
+
495
+ - **Visual Elements**
496
+ - Color-coded pass/fail indicators (✅/❌)
497
+ - Expandable request/response sections
498
+ - Timing charts
499
+ - Interactive HTML with filtering
500
+
501
+ ### Report Example
502
+
503
+ ```javascript
504
+ // Generate comprehensive report
505
+ await tools.api_session_report({
506
+ sessionId: "test-execution-books-api-1739597400000",
507
+ outputPath: "./api-test-reports/books-api-execution-report.html"
508
+ })
509
+
510
+ // Report file created at:
511
+ // ./api-test-reports/books-api-execution-report.html
512
+
513
+ // Open in browser to view:
514
+ // - 15 total requests
515
+ // - 13 passed (86.7%)
516
+ // - 2 failed (13.3%)
517
+ // - Average response time: 145ms
518
+ // - Total execution time: 2.3s
519
+ ```
520
+
521
+ ## Advanced Scenarios
522
+
523
+ ### Scenario 1: Testing with Authentication
524
+
525
+ ```javascript
526
+ // Step 1: Authenticate first
527
+ await tools.api_request({
528
+ sessionId: sessionId,
529
+ method: "POST",
530
+ url: "https://api.example.com/auth/login",
531
+ data: {
532
+ email: "test@example.com",
533
+ password: "password123"
534
+ },
535
+ expect: { status: 200 },
536
+ extract: { "authToken": "access_token" }
537
+ })
538
+
539
+ // Step 2: Use token in subsequent requests
540
+ await tools.api_request({
541
+ sessionId: sessionId,
542
+ method: "GET",
543
+ url: "https://api.example.com/api/v1/protected-resource",
544
+ headers: {
545
+ "Authorization": "Bearer {{authToken}}" // Uses extracted token
546
+ },
547
+ expect: { status: 200 }
548
+ })
549
+ ```
550
+
551
+ ### Scenario 2: Testing CRUD Operations
552
+
553
+ ```javascript
554
+ const sessionId = `test-execution-crud-${Date.now()}`;
555
+
556
+ // CREATE
557
+ await tools.api_request({
558
+ sessionId: sessionId,
559
+ method: "POST",
560
+ url: "https://api.example.com/api/v1/Books",
561
+ data: { title: "Test Book", author: "Test Author" },
562
+ expect: { status: 201 },
563
+ extract: { "newBookId": "id" }
564
+ })
565
+
566
+ // READ
567
+ await tools.api_request({
568
+ sessionId: sessionId,
569
+ method: "GET",
570
+ url: "https://api.example.com/api/v1/Books/{{newBookId}}",
571
+ expect: { status: 200 }
572
+ })
573
+
574
+ // UPDATE
575
+ await tools.api_request({
576
+ sessionId: sessionId,
577
+ method: "PUT",
578
+ url: "https://api.example.com/api/v1/Books/{{newBookId}}",
579
+ data: { title: "Updated Book", author: "Test Author" },
580
+ expect: { status: 200 }
581
+ })
582
+
583
+ // DELETE
584
+ await tools.api_request({
585
+ sessionId: sessionId,
586
+ method: "DELETE",
587
+ url: "https://api.example.com/api/v1/Books/{{newBookId}}",
588
+ expect: { status: 204 }
589
+ })
590
+
591
+ // Generate report showing complete CRUD workflow
592
+ await tools.api_session_report({
593
+ sessionId: sessionId,
594
+ outputPath: "./api-test-reports/crud-test-report.html"
595
+ })
596
+ ```
597
+
598
+ ### Scenario 3: Parallel Execution (Multiple Sessions)
599
+
600
+ ```javascript
601
+ // Execute different sections in parallel
602
+ const session1 = `test-execution-books-${Date.now()}`;
603
+ const session2 = `test-execution-users-${Date.now()}`;
604
+ const session3 = `test-execution-orders-${Date.now()}`;
605
+
606
+ // Run tests for different sections independently
607
+ // Note: These should be awaited sequentially or use Promise.all if truly parallel
608
+
609
+ // Generate individual reports
610
+ await tools.api_session_report({
611
+ sessionId: session1,
612
+ outputPath: "./api-test-reports/books-report.html"
613
+ })
614
+
615
+ await tools.api_session_report({
616
+ sessionId: session2,
617
+ outputPath: "./api-test-reports/users-report.html"
618
+ })
619
+
620
+ await tools.api_session_report({
621
+ sessionId: session3,
622
+ outputPath: "./api-test-reports/orders-report.html"
623
+ })
624
+ ```
625
+
626
+ ## Best Practices
627
+
628
+ ### DO:
629
+ - Use unique, descriptive session IDs for each test run
630
+ - Parse test plan systematically (base URL, auth, sections)
631
+ - Execute tests in logical order (auth first, dependencies second)
632
+ - Use request chaining for dependent tests (extract/reuse IDs)
633
+ - Generate comprehensive HTML reports after execution
634
+ - Handle test failures gracefully (continue with remaining tests)
635
+ - Provide clear progress updates to user during execution
636
+ - Validate responses using expect parameters
637
+ - Use consistent session naming conventions
638
+
639
+ ### DON'T:
640
+ - Don't reuse session IDs across different test runs
641
+ - Don't skip authentication if test plan requires it
642
+ - Don't execute dependent tests out of order
643
+ - Don't forget to generate the final HTML report
644
+ - Don't stop execution on first failure (unless critical)
645
+ - Don't ignore validation criteria from test plan
646
+ - Don't execute tests without parsing test plan structure first
647
+ - Don't forget to extract base URL from test plan
648
+
649
+ ## Expected Output
650
+
651
+ After successful test execution, provide user with:
652
+
653
+ 1. **Execution Summary:**
654
+ ```
655
+ Test Execution Summary:
656
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
657
+ Session ID: test-execution-books-api-1739597400000
658
+ Total Tests: 15
659
+ Passed: 13 (86.7%)
660
+ Failed: 2 (13.3%)
661
+ Execution Time: 2.3s
662
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
663
+
664
+ Test Results:
665
+ ✅ GET /api/v1/Books - List all books
666
+ ✅ GET /api/v1/Books/{id} - Get book by ID
667
+ ✅ POST /api/v1/Books - Create new book
668
+ ❌ PUT /api/v1/Books/{id} - Update book (404 Not Found)
669
+ ✅ DELETE /api/v1/Books/{id} - Delete book
670
+ ...
671
+
672
+ 📊 HTML Report Generated:
673
+ ./api-test-reports/books-api-execution-report.html
674
+
675
+ Open this file in a browser for detailed analysis!
676
+ ```
677
+
678
+ 2. **Failed Test Details:**
679
+ ```
680
+ Failed Tests:
681
+
682
+ ❌ PUT /api/v1/Books/{id}
683
+ Expected: 200 OK
684
+ Actual: 404 Not Found
685
+ Response: {"error": "Book not found"}
686
+
687
+ Possible causes:
688
+ - Book ID may have been deleted
689
+ - Endpoint URL may have changed
690
+ - Authentication may have expired
691
+ ```
692
+
693
+ 3. **Next Steps:**
694
+ ```
695
+ Next Steps:
696
+ 1. Open HTML report for detailed analysis
697
+ 2. Review failed tests and fix issues
698
+ 3. Re-run failed tests or use /test-healing skill
699
+ 4. Update test plan if API has changed
700
+ ```
701
+
702
+ ## Integration with Other Skills
703
+
704
+ ### After API Planning → Execute Tests
705
+ ```
706
+ 1. User: /api-planning create test plan for API
707
+ → Test plan generated
708
+
709
+ 2. User: /test-execution run tests from section 1
710
+ → Tests executed, report generated
711
+ ```
712
+
713
+ ### Execute → Heal → Re-execute
714
+ ```
715
+ 1. User: /test-execution run all tests
716
+ → Some tests fail
717
+
718
+ 2. User: /test-healing fix failed tests
719
+ → Tests updated with fixes
720
+
721
+ 3. User: /test-execution re-run failed tests
722
+ → All tests pass now
723
+ ```
724
+
725
+ ### Execute → Generate Code → Execute Again
726
+ ```
727
+ 1. User: /test-execution run quick validation
728
+ → Quick API validation completed
729
+
730
+ 2. User: /test-generation create Playwright tests
731
+ → Executable test code generated
732
+
733
+ 3. User: Run generated Playwright tests
734
+ → Automated test suite running
735
+ ```
736
+
737
+ ## Troubleshooting
738
+
739
+ ### Issue: Base URL not found in test plan
740
+ - Check test plan overview section
741
+ - Ask user to provide base URL
742
+ - Look for API URL in first few sections
743
+
744
+ ### Issue: Cannot parse test sections
745
+ - Verify test plan uses markdown headers (##)
746
+ - Check section titles include HTTP method
747
+ - Ensure sections have required fields (endpoint, status)
748
+
749
+ ### Issue: Authentication failures (401/403)
750
+ - Extract auth requirements from test plan
751
+ - Execute auth endpoint first
752
+ - Use extracted tokens in subsequent requests
753
+
754
+ ### Issue: Request chaining not working
755
+ - The skill will automatically try common extraction paths — check the session log to see what path resolved and what value was found
756
+ - If all common paths fail, inspect the raw response body in the session log and look for the field manually
757
+ - Ensure the variable name used in `{{variableName}}` matches exactly what was extracted
758
+ - Never pass an empty variable into a URL — the skill should halt and report before this happens
759
+
760
+ ### Issue: Tests fail with timeouts
761
+ - Check API availability
762
+ - Verify network connectivity
763
+ - Consider increasing timeout in api_request
764
+
765
+ ### Issue: Report not generated
766
+ - Ensure session ID is correct
767
+ - Verify api_session_report is called after all tests
768
+ - Check output path is valid
769
+
770
+ ## Additional Tools Available
771
+
772
+ Use these tools as needed:
773
+ - `api_request` - Execute individual API requests
774
+ - `api_session_status` - Check test execution progress
775
+ - `api_session_report` - Generate HTML test reports
776
+ - `search/readFile` - Read test plan files
777
+ - `search/listDirectory` - Find test plan files