@swedevtools/livedoc-vitest 0.2.0 → 0.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/CHANGELOG.md +34 -0
- package/LICENSE +20 -20
- package/README.md +160 -95
- package/dist/{RuleContext-BZhuy-zS.d.cts → RuleContext-DQ8o_n1D.d.ts} +62 -62
- package/dist/globals.d.ts +99 -99
- package/dist/{index-Blmp569T.d.cts → index-sbV15ohX.d.ts} +21 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1062 -159
- package/dist/reporter/index.d.ts +2 -2
- package/dist/reporter/index.js +629 -84
- package/package.json +14 -12
- package/tools/livedoc-setup.mjs +172 -164
- package/tools/skills/SKILL.md +339 -244
- package/tools/skills/VALIDATION.md +37 -29
- package/tools/skills/examples/routing.md +75 -60
- package/tools/skills/resources/anti-patterns.md +19 -0
- package/tools/skills/resources/bdd-features.md +231 -231
- package/tools/skills/resources/partial-testing.md +77 -0
- package/tools/skills/resources/playwright.md +148 -148
- package/tools/skills/resources/reporter-config.md +213 -163
- package/tools/skills/resources/specifications.md +159 -159
- package/tools/skills/resources/test-strategy.md +103 -0
- package/tools/skills/resources/web-testing.md +62 -0
- package/dist/RuleContext-BZhuy-zS.d.ts +0 -206
- package/dist/globals.cjs +0 -2
- package/dist/globals.d.cts +0 -104
- package/dist/index-CysiWbtk.d.ts +0 -687
- package/dist/index.cjs +0 -10024
- package/dist/index.d.cts +0 -291
- package/dist/playwright/index.cjs +0 -103
- package/dist/playwright/index.d.cts +0 -129
- package/dist/reporter/index.cjs +0 -8676
- package/dist/reporter/index.d.cts +0 -7
- package/dist/setup.cjs +0 -14
- package/dist/setup.d.cts +0 -2
package/tools/skills/SKILL.md
CHANGED
|
@@ -1,244 +1,339 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: livedoc-vitest
|
|
3
|
-
description: Expert guidance for writing and modifying BDD/Gherkin and MSpec-style tests using the @swedevtools/livedoc-vitest framework. Generates self-documenting TypeScript specs with correct API usage, value extraction, and living documentation patterns.
|
|
4
|
-
sdk_version: 0.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# LiveDoc Vitest Test Author
|
|
8
|
-
|
|
9
|
-
> **Progressive disclosure**: This file is the routing hub. Read the appropriate sub-resource for full API details.
|
|
10
|
-
|
|
11
|
-
## Version Check
|
|
12
|
-
|
|
13
|
-
This skill targets **@swedevtools/livedoc-vitest v0.
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm ls @swedevtools/livedoc-vitest # or: pnpm ls @swedevtools/livedoc-vitest
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
If the installed version differs from `0.
|
|
20
|
-
|
|
21
|
-
## Use this skill when
|
|
22
|
-
- Creating or modifying `.Spec.ts` test files using `@swedevtools/livedoc-vitest`
|
|
23
|
-
- Writing BDD `feature`/`scenario` tests → **read `resources/bdd-features.md`**
|
|
24
|
-
- Writing MSpec `specification`/`rule` tests → **read `resources/specifications.md`**
|
|
25
|
-
- Writing browser-based Playwright tests → **read `resources/playwright.md`**
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- Writing
|
|
33
|
-
- Working on
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
1
|
+
---
|
|
2
|
+
name: livedoc-vitest
|
|
3
|
+
description: Expert guidance for writing and modifying BDD/Gherkin and MSpec-style tests using the @swedevtools/livedoc-vitest framework. Generates self-documenting TypeScript specs with correct API usage, value extraction, and living documentation patterns.
|
|
4
|
+
sdk_version: 0.3.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# LiveDoc Vitest Test Author
|
|
8
|
+
|
|
9
|
+
> **Progressive disclosure**: This file is the routing hub. Read the appropriate sub-resource for full API details.
|
|
10
|
+
|
|
11
|
+
## Version Check
|
|
12
|
+
|
|
13
|
+
This skill targets **@swedevtools/livedoc-vitest v0.3.0**. Before writing tests, verify the installed version matches:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm ls @swedevtools/livedoc-vitest # or: pnpm ls @swedevtools/livedoc-vitest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If the installed version differs from `0.3.0`, tell the developer: *"Your LiveDoc skill files target v0.3.0 but you have vX.Y.Z installed. Run `npx livedoc-vitest-setup` to update the skill files, or check the changelog for breaking changes."*
|
|
20
|
+
|
|
21
|
+
## Use this skill when
|
|
22
|
+
- Creating or modifying `.Spec.ts` test files using `@swedevtools/livedoc-vitest`
|
|
23
|
+
- Writing BDD `feature`/`scenario` tests → **read `resources/bdd-features.md`**
|
|
24
|
+
- Writing MSpec `specification`/`rule` tests → **read `resources/specifications.md`**
|
|
25
|
+
- Writing browser-based Playwright tests → **read `resources/web-testing.md` and `resources/playwright.md`**
|
|
26
|
+
- Running tag-scoped incremental tests that patch the Viewer → **read `resources/partial-testing.md`**
|
|
27
|
+
- Configuring reporters or static HTML export → **read `resources/reporter-config.md`**
|
|
28
|
+
- Configuring Vitest coverage for LiveDoc Viewer → **read `resources/reporter-config.md`**
|
|
29
|
+
- Debugging or fixing any LiveDoc Vitest test failures
|
|
30
|
+
|
|
31
|
+
## Do not use this skill when
|
|
32
|
+
- Writing C#/.NET xUnit tests (use `livedoc-xunit` skill instead)
|
|
33
|
+
- Working on non-test TypeScript code (application logic, UI components, build scripts)
|
|
34
|
+
- Writing plain Vitest tests without LiveDoc BDD/Specification patterns
|
|
35
|
+
- Working on the viewer, VS Code extension, or server packages (unless writing their specs)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Inputs
|
|
40
|
+
|
|
41
|
+
- Behavior claim or defect to protect
|
|
42
|
+
- Relevant production code and existing tests
|
|
43
|
+
- Observable boundary: pure code, component, HTTP, browser, process, filesystem, or source tree
|
|
44
|
+
- Vitest configuration and installed package versions
|
|
45
|
+
|
|
46
|
+
## Outputs
|
|
47
|
+
|
|
48
|
+
- The smallest trustworthy LiveDoc test, or a recommendation to use a native specialist test
|
|
49
|
+
- Self-documenting titles with values extracted through LiveDoc context APIs
|
|
50
|
+
- Focused validation evidence, including isolated execution and false-green checks
|
|
51
|
+
- A clean LiveDoc report with no unintended rule violations
|
|
52
|
+
- A user-approved, sanitized upstream bug report when testing confirms a LiveDoc framework defect
|
|
53
|
+
|
|
54
|
+
## Workflow
|
|
55
|
+
|
|
56
|
+
1. Read `resources/test-strategy.md` and apply the two-question litmus.
|
|
57
|
+
2. Choose the lowest trustworthy boundary and an independent oracle.
|
|
58
|
+
3. Select Feature or Specification based on audience and journey shape.
|
|
59
|
+
4. For web claims, read `resources/web-testing.md`; do not use class names as appearance proxies.
|
|
60
|
+
5. Implement one reported row per independent claim using the matching syntax resource.
|
|
61
|
+
6. Review `resources/anti-patterns.md`.
|
|
62
|
+
7. For incremental validation, read `resources/partial-testing.md` and prefer affected tags over file or title filters.
|
|
63
|
+
8. Run the focused test alone, then its normal suite.
|
|
64
|
+
9. Inspect the LiveDoc output for rule violations and follow **Rule Violation Self-Correction** until no unintended violations remain.
|
|
65
|
+
10. Apply the false-green validation gate.
|
|
66
|
+
11. If the evidence indicates a LiveDoc framework defect, follow **Framework Defect Escalation**.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Two Test Patterns
|
|
71
|
+
|
|
72
|
+
### 1. BDD Features (`resources/bdd-features.md`)
|
|
73
|
+
|
|
74
|
+
**Use when**: Testing user journeys, business flows, acceptance criteria. Audience is business + technical. Tests read as Given/When/Then narratives.
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { feature, scenario, given, when, Then as then } from "@swedevtools/livedoc-vitest";
|
|
78
|
+
|
|
79
|
+
feature("Shipping Costs", () => {
|
|
80
|
+
scenario("Free shipping for Australian orders over $100", () => {
|
|
81
|
+
let cart: ShoppingCart;
|
|
82
|
+
|
|
83
|
+
given("the customer is from 'Australia'", (ctx) => {
|
|
84
|
+
cart = new ShoppingCart({ country: ctx.step.values[0] });
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
when("the order totals '100.00' dollars", (ctx) => {
|
|
88
|
+
cart.total = ctx.step.values[0];
|
|
89
|
+
cart.calculate();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
then("shipping type is 'Free'", (ctx) => {
|
|
93
|
+
expect(cart.shippingType).toBe(ctx.step.values[0]);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Key concepts**: `feature`, `scenario`, `scenarioOutline`, `background`, `given`/`when`/`then`/`and`/`but`, `ctx.step.values`, `ctx.step.params`, `ctx.example`, data tables, doc strings.
|
|
100
|
+
|
|
101
|
+
→ **Read `resources/bdd-features.md`** for complete keyword reference, background patterns, scenarioOutline with Examples, value extraction API, data tables, doc strings, attachment API, and validation checklist.
|
|
102
|
+
|
|
103
|
+
### 2. Specifications (`resources/specifications.md`)
|
|
104
|
+
|
|
105
|
+
**Use when**: Testing APIs, utilities, algorithms, data-driven edge cases. Developer-only audience. Direct assertions in rules — no Given/When/Then ceremony.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import { specification, rule, ruleOutline } from "@swedevtools/livedoc-vitest";
|
|
109
|
+
|
|
110
|
+
specification("Calculator Operations", () => {
|
|
111
|
+
rule("Adding '5' and '3' returns '8'", (ctx) => {
|
|
112
|
+
const [a, b, expected] = ctx.rule.values;
|
|
113
|
+
expect(a + b).toBe(expected);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
ruleOutline(`Discount calculations
|
|
117
|
+
Examples:
|
|
118
|
+
| price | discount | expected |
|
|
119
|
+
| 100 | 10 | 90 |
|
|
120
|
+
| 200 | 25 | 150 |
|
|
121
|
+
`, (ctx) => {
|
|
122
|
+
const result = ctx.example.price - (ctx.example.price * ctx.example.discount / 100);
|
|
123
|
+
expect(result).toBe(ctx.example.expected);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Key concepts**: `specification`, `rule`, `ruleOutline`, `ctx.rule.values`, `ctx.rule.params`, `ctx.example`, data-driven testing.
|
|
129
|
+
|
|
130
|
+
→ **Read `resources/specifications.md`** for complete keyword reference, value extraction API, ruleOutline with Examples, async rules, and validation checklist.
|
|
131
|
+
|
|
132
|
+
### 3. Playwright Integration (`resources/playwright.md`)
|
|
133
|
+
|
|
134
|
+
**Use when**: Browser-based testing — UI validation, screenshot capture, end-to-end web testing.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { useBrowser, screenshot } from "@swedevtools/livedoc-vitest/playwright";
|
|
138
|
+
|
|
139
|
+
const { page } = useBrowser();
|
|
140
|
+
|
|
141
|
+
// Inside a scenario step:
|
|
142
|
+
when("navigating to the homepage", async (ctx) => {
|
|
143
|
+
await page().goto("http://localhost:3000");
|
|
144
|
+
await screenshot(page(), ctx);
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
→ **Read `resources/web-testing.md`** to choose jsdom or a real browser, then
|
|
149
|
+
**read `resources/playwright.md`** for `useBrowser`, screenshots, lifecycle, and troubleshooting.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Shared Concepts
|
|
154
|
+
|
|
155
|
+
### Folder Structure = Report Hierarchy
|
|
156
|
+
|
|
157
|
+
The **file path** of each `.Spec.ts` file determines the visual tree in the LiveDoc Viewer:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
_src/test/
|
|
161
|
+
├── Checkout/ → "Checkout" node in viewer
|
|
162
|
+
│ └── Cart.Spec.ts
|
|
163
|
+
├── Shipping/ → "Shipping" node
|
|
164
|
+
│ └── Costs.Spec.ts
|
|
165
|
+
└── Auth/ → "Auth" node
|
|
166
|
+
└── Login.Spec.ts
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Import Pattern
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
// BDD pattern
|
|
173
|
+
import { feature, scenario, scenarioOutline, background, given, when, Then as then, and, but } from "@swedevtools/livedoc-vitest";
|
|
174
|
+
|
|
175
|
+
// Specification pattern
|
|
176
|
+
import { specification, rule, ruleOutline } from "@swedevtools/livedoc-vitest";
|
|
177
|
+
|
|
178
|
+
// Playwright (optional)
|
|
179
|
+
import { useBrowser, screenshot } from "@swedevtools/livedoc-vitest/playwright";
|
|
180
|
+
|
|
181
|
+
// Or use globals mode — requires BOTH settings in vitest.config.ts:
|
|
182
|
+
// globals: true
|
|
183
|
+
// setupFiles: ['@swedevtools/livedoc-vitest/setup']
|
|
184
|
+
// Note: globals mode only registers BDD keywords (feature, scenario, given, when, then, etc.)
|
|
185
|
+
// Specification keywords (specification, rule, ruleOutline) must still be imported explicitly.
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**CRITICAL**: Import `Then` (uppercase) and alias as `then` (lowercase). ESM thenable detection requires the uppercase export name.
|
|
189
|
+
|
|
190
|
+
### CRITICAL: Self-Documenting Tests
|
|
191
|
+
|
|
192
|
+
**Embed all inputs and expected outputs in step/rule titles.** Extract them using context APIs. Never hardcode values that appear in titles.
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// ✅ Values in title AND extracted from context
|
|
196
|
+
given("a user with balance '500' dollars", (ctx) => {
|
|
197
|
+
account.balance = ctx.step.values[0]; // 500
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// ✅ Named parameters for clarity
|
|
201
|
+
given("a user with <balance:500> dollars", (ctx) => {
|
|
202
|
+
account.balance = ctx.step.params.balance; // 500
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// ❌ BAD: Value drift — title says 500, code uses 200
|
|
206
|
+
given("a user with balance '500' dollars", (ctx) => {
|
|
207
|
+
account.balance = 200;
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Value Extraction Quick Reference
|
|
212
|
+
|
|
213
|
+
| Syntax in Title | Step Access | Rule Access |
|
|
214
|
+
| --- | --- | --- |
|
|
215
|
+
| `'value'` (quoted) | `ctx.step.values[0]` | `ctx.rule.values[0]` |
|
|
216
|
+
| `<name:value>` (named) | `ctx.step.params.name` | `ctx.rule.params.name` |
|
|
217
|
+
| `<Placeholder>` (outline) | `ctx.example.Placeholder` | `ctx.example.Placeholder` |
|
|
218
|
+
|
|
219
|
+
### Descriptions and Tags
|
|
220
|
+
|
|
221
|
+
Lines after the first line in titles provide descriptions and tags:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
feature(`Shopping Cart
|
|
225
|
+
@checkout @critical
|
|
226
|
+
Business rules for the shopping cart checkout flow.
|
|
227
|
+
`, () => { ... });
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- **First line** = title
|
|
231
|
+
- **Lines starting with `@`** = tags (used for filtering)
|
|
232
|
+
- **Remaining lines** = description (appears in reports)
|
|
233
|
+
|
|
234
|
+
### Async Rules
|
|
235
|
+
|
|
236
|
+
- **Only step callbacks, `rule`, and `ruleOutline` support `async`**
|
|
237
|
+
- `feature`, `scenario`, `scenarioOutline`, `specification`, `background` must be **synchronous**
|
|
238
|
+
|
|
239
|
+
### Modifiers
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
feature.only("...", fn); feature.skip("...", fn);
|
|
243
|
+
scenario.only("...", fn); scenario.skip("...", fn);
|
|
244
|
+
rule.only("...", fn); rule.skip("...", fn);
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Build and Test
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
pnpm --filter @swedevtools/livedoc-vitest test # Run all specs
|
|
251
|
+
pnpm --filter @swedevtools/livedoc-vitest test MyFeature.Spec.ts
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Tag-Scoped Partial Runs
|
|
255
|
+
|
|
256
|
+
After publishing a full baseline, use tags with `LIVEDOC_RUN_TYPE=partial` so
|
|
257
|
+
focused validation patches the Viewer without replacing unaffected results.
|
|
258
|
+
Read `resources/partial-testing.md` for the setup convention and commands.
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Rule Violation Self-Correction
|
|
263
|
+
|
|
264
|
+
LiveDoc rule violations are validation failures even when Vitest exits successfully. Every time tests are created, modified, or validated:
|
|
265
|
+
|
|
266
|
+
1. Run the affected tests with a LiveDoc reporter and inspect the reported model/summary, not only the Vitest exit code.
|
|
267
|
+
2. Enumerate every rule violation and its owning feature, scenario, rule, or step.
|
|
268
|
+
3. Fix the test structure named by the violation. Use meaningful Given/When/Then flows for Features and Specifications for technical assertions without a behavioral journey.
|
|
269
|
+
4. Do not silence violations with filler/no-op steps, blanket suppression, or weaker rules. Each step must communicate and observe real behavior.
|
|
270
|
+
5. Keep deliberate invalid-structure tests in isolated dynamic/probe executions so the normal report remains clean.
|
|
271
|
+
6. Rerun the affected tests and normal report until unintended rule violations equal zero.
|
|
272
|
+
|
|
273
|
+
A violation usually indicates a test-authoring defect, not a framework defect. Escalate upstream only when a minimal valid test produces an incorrect or missing violation.
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Framework Defect Escalation
|
|
278
|
+
|
|
279
|
+
Treat a confirmed LiveDoc framework defect as an actionable outcome. Proactively recommend an upstream report rather than waiting for the developer to request one, but never publish an issue or comment without explicit user approval.
|
|
280
|
+
|
|
281
|
+
1. **Classify the failure** — confirm the behavior occurs at the LiveDoc public API, runtime, discovery, filtering, or reporting boundary. Do not report consumer application bugs, incorrect expectations, unsupported usage, or configuration mistakes as framework defects.
|
|
282
|
+
2. **Minimize and verify** — reproduce with the smallest standalone `.Spec.ts`, the installed compatible LiveDoc version, and the normal test command. Record expected versus actual behavior and prove the test would pass if the suspected defect were absent.
|
|
283
|
+
3. **Check for duplicates** — search open and closed issues in `dotnetprofessional/LiveDoc` using the API name, symptom, error text, and likely subsystem. Prefer adding new evidence to an existing issue over filing a duplicate.
|
|
284
|
+
4. **Sanitize the evidence** — remove credentials, proprietary code, personal data, private URLs, organization names, and machine-specific paths. Replace them with minimal neutral fixtures.
|
|
285
|
+
5. **Draft one focused report per defect** — include summary, minimal reproduction, actual behavior, expected behavior, workaround, exact package/Vitest/Node versions, operating system, command, and relevant output.
|
|
286
|
+
6. **Request consent** — show the draft or a concise summary and ask one focused approval question before creating an issue or commenting. If the user declines, retain the draft in the response and continue without any external side effect.
|
|
287
|
+
7. **Publish after approval** — verify the active GitHub identity and target `dotnetprofessional/LiveDoc`. For repository maintenance, use the configured `dotnetprofessional` account when available and authorized. Follow the repository issue template, search once more for duplicates, then return the created issue URL.
|
|
288
|
+
|
|
289
|
+
If authentication, permissions, or network access prevents submission, preserve the complete draft and report the exact blocker. Never silently skip a confirmed defect or claim that it was filed.
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## Validation
|
|
294
|
+
|
|
295
|
+
- [ ] The test passes the two-question litmus.
|
|
296
|
+
- [ ] The instrument can observe the behavior named in the title.
|
|
297
|
+
- [ ] The intended test was collected and executed.
|
|
298
|
+
- [ ] Values are visible in titles and extracted from context.
|
|
299
|
+
- [ ] Expected results are independent of production logic.
|
|
300
|
+
- [ ] The test passes alone and in its normal suite.
|
|
301
|
+
- [ ] The LiveDoc report contains zero unintended rule violations.
|
|
302
|
+
- [ ] Incremental validation uses the smallest affected tag set and publishes as `partial`.
|
|
303
|
+
- [ ] Critical behavior has been observed failing for the intended defect.
|
|
304
|
+
- [ ] Attachments contain no secrets and supplement assertions.
|
|
305
|
+
- [ ] Any suspected LiveDoc framework defect was disproved or handled through the escalation workflow.
|
|
306
|
+
|
|
307
|
+
## Examples
|
|
308
|
+
|
|
309
|
+
### Positive routing examples
|
|
310
|
+
- "Create a BDD test for shipping costs" → Read `resources/bdd-features.md`, write feature/scenario
|
|
311
|
+
- "Add data-driven tests for tax" → Read `resources/bdd-features.md`, use scenarioOutline
|
|
312
|
+
- "Write spec tests for email validator" → Read `resources/specifications.md`, write specification/rule
|
|
313
|
+
- "Write a Playwright test for the login page" → Read `resources/web-testing.md` and `resources/playwright.md`
|
|
314
|
+
- "Verify a responsive touch target" → Use a real browser and measure geometry
|
|
315
|
+
- "Configure LiveDoc reporter output" → Read `resources/reporter-config.md`
|
|
316
|
+
- "Configure LiveDoc coverage" → Read `resources/reporter-config.md`; install the provider matching the Vitest version
|
|
317
|
+
- "Generate static HTML test report" → Read `resources/reporter-config.md`
|
|
318
|
+
- "Validate changed checkout behavior incrementally" → Read `resources/partial-testing.md`; run affected tags as a partial
|
|
319
|
+
- "Tests pass but LiveDoc reports rule violations" → Fix the test semantics and rerun until the normal report is clean
|
|
320
|
+
- "This minimal LiveDoc spec reveals a framework bug" → Verify, deduplicate, sanitize, draft, and request approval to report it
|
|
321
|
+
|
|
322
|
+
### Negative routing examples
|
|
323
|
+
- "Create a C# test for shipping" → Use `livedoc-xunit` skill
|
|
324
|
+
- "Build a React component" → Use `frontend-design` skill
|
|
325
|
+
- "Write a plain vitest test" → No LiveDoc skill needed
|
|
326
|
+
- "Convert every low-level test to LiveDoc" → Decline; curate only behavior with lasting documentation value
|
|
327
|
+
- "Install AI skills for the team" → Run `npx livedoc-vitest-setup`
|
|
328
|
+
|
|
329
|
+
## Failure Handling
|
|
330
|
+
- Tests fail to compile → check imports, especially `Then as then` alias
|
|
331
|
+
- Values are `undefined` → verify single quotes `'value'` not backticks or double quotes
|
|
332
|
+
- `ctx.example` undefined → ensure inside `scenarioOutline`/`ruleOutline`, not plain `scenario`/`rule`
|
|
333
|
+
- Async hangs → ensure `async` only on step/rule callbacks, not on `feature`/`scenario`
|
|
334
|
+
- Playwright `page()` throws → `useBrowser()` must be at module scope; `page()` called inside steps
|
|
335
|
+
- Partial run replaces the full Viewer picture → ensure `LIVEDOC_RUN_TYPE=partial` and a full baseline already exists
|
|
336
|
+
- Tag filter selects nothing → verify the setup file reads `LIVEDOC_TAGS` and normalizes the `@` prefix
|
|
337
|
+
- Reporter issues → Read `resources/reporter-config.md`
|
|
338
|
+
- Rule violations remain after a green test run → treat the run as failed and follow **Rule Violation Self-Correction**
|
|
339
|
+
- Suspected LiveDoc framework bug → follow **Framework Defect Escalation**; do not publish without user approval
|