@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
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
# Validation Report — livedoc-vitest
|
|
2
|
-
|
|
3
|
-
## Result: PASS
|
|
4
|
-
|
|
5
|
-
## Checks
|
|
6
|
-
|
|
7
|
-
| Check | Status |
|
|
8
|
-
| --- | --- |
|
|
9
|
-
| Frontmatter `name` present | ✅ |
|
|
10
|
-
| Frontmatter `description` present | ✅ |
|
|
11
|
-
| Description ≤ 100 words | ✅ (
|
|
12
|
-
| Body ≤ 500 lines | ✅ (
|
|
13
|
-
| `## Use this skill when` | ✅ |
|
|
14
|
-
| `## Do not use this skill when` | ✅ |
|
|
15
|
-
| `## Inputs` | ✅ |
|
|
16
|
-
| `## Outputs` | ✅ |
|
|
17
|
-
| `## Workflow` | ✅ |
|
|
18
|
-
| `## Validation` | ✅ |
|
|
19
|
-
| `## Examples` | ✅ |
|
|
20
|
-
| `### Positive routing examples` | ✅ |
|
|
21
|
-
| `### Negative routing examples` | ✅ |
|
|
22
|
-
| `## Failure handling` | ✅ |
|
|
23
|
-
| Routing examples file (`examples/routing.md`) | ✅ |
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
# Validation Report — livedoc-vitest
|
|
2
|
+
|
|
3
|
+
## Result: PASS
|
|
4
|
+
|
|
5
|
+
## Checks
|
|
6
|
+
|
|
7
|
+
| Check | Status |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| Frontmatter `name` present | ✅ |
|
|
10
|
+
| Frontmatter `description` present | ✅ |
|
|
11
|
+
| Description ≤ 100 words | ✅ (28 words) |
|
|
12
|
+
| Body ≤ 500 lines | ✅ (334 lines) |
|
|
13
|
+
| `## Use this skill when` | ✅ |
|
|
14
|
+
| `## Do not use this skill when` | ✅ |
|
|
15
|
+
| `## Inputs` | ✅ |
|
|
16
|
+
| `## Outputs` | ✅ |
|
|
17
|
+
| `## Workflow` | ✅ |
|
|
18
|
+
| `## Validation` | ✅ |
|
|
19
|
+
| `## Examples` | ✅ |
|
|
20
|
+
| `### Positive routing examples` | ✅ |
|
|
21
|
+
| `### Negative routing examples` | ✅ |
|
|
22
|
+
| `## Failure handling` | ✅ |
|
|
23
|
+
| Routing examples file (`examples/routing.md`) | ✅ |
|
|
24
|
+
| Boundary-first strategy resource | ✅ |
|
|
25
|
+
| jsdom/real-browser guidance | ✅ |
|
|
26
|
+
| False-green anti-pattern catalogue | ✅ |
|
|
27
|
+
| Tag-scoped partial-testing workflow | ✅ |
|
|
28
|
+
| Framework defect verification and duplicate search | ✅ |
|
|
29
|
+
| Sanitized draft and explicit consent before submission | ✅ |
|
|
30
|
+
| Rule-violation self-correction gate | ✅ |
|
|
31
|
+
| Source and package-shipped copies aligned | ✅ |
|
|
32
|
+
|
|
33
|
+
## Assumptions
|
|
34
|
+
- Tests are written in TypeScript and use Vitest as the test runner
|
|
35
|
+
- The `@swedevtools/livedoc-vitest` package is available in the monorepo via `workspace:*`
|
|
36
|
+
- Globals mode may or may not be enabled; skill covers both import and globals patterns
|
|
37
|
+
- The existing `.github/instructions/livedoc-vitest.instructions.md` remains the file-pattern instruction; this skill provides broader AI-agent guidance
|
|
@@ -1,60 +1,75 @@
|
|
|
1
|
-
# LiveDoc Vitest Skill — Routing Examples
|
|
2
|
-
|
|
3
|
-
## Positive routing (USE this skill)
|
|
4
|
-
|
|
5
|
-
### Example 1: Create a new BDD feature spec
|
|
6
|
-
> "Create a test for the shopping cart checkout flow"
|
|
7
|
-
|
|
8
|
-
→ This involves writing a `.Spec.ts` file using `feature`, `scenario`, `given`/`when`/`then` from `@swedevtools/livedoc-vitest`.
|
|
9
|
-
|
|
10
|
-
### Example 2: Add a scenario outline with examples
|
|
11
|
-
> "Add data-driven tests for email validation"
|
|
12
|
-
|
|
13
|
-
→ This involves using `scenarioOutline` or `ruleOutline` with an Examples table and `ctx.example`.
|
|
14
|
-
|
|
15
|
-
### Example 3: Fix value extraction in a step
|
|
16
|
-
> "The step says '500' but the test uses 200 — fix the value drift"
|
|
17
|
-
|
|
18
|
-
→ This involves replacing hardcoded values with `ctx.step.values[0]` or `ctx.step.params`.
|
|
19
|
-
|
|
20
|
-
### Example 4: Convert a plain vitest test to LiveDoc specification pattern
|
|
21
|
-
> "Rewrite these unit tests as a LiveDoc specification with rules"
|
|
22
|
-
|
|
23
|
-
→ This involves using `specification` and `rule`/`ruleOutline` from `@swedevtools/livedoc-vitest`.
|
|
24
|
-
|
|
25
|
-
### Example 5: Modify an existing spec file
|
|
26
|
-
> "Add a new scenario to UserAuth.Spec.ts for password reset"
|
|
27
|
-
|
|
28
|
-
→ This involves editing an existing `.Spec.ts` file using the correct LiveDoc patterns.
|
|
29
|
-
|
|
30
|
-
### Example 6: Write a browser test with Playwright
|
|
31
|
-
> "Write a Playwright test that checks the viewer homepage loads correctly"
|
|
32
|
-
|
|
33
|
-
→
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### Example
|
|
48
|
-
> "
|
|
49
|
-
|
|
50
|
-
→
|
|
51
|
-
|
|
52
|
-
### Example
|
|
53
|
-
> "
|
|
54
|
-
|
|
55
|
-
→ This is
|
|
56
|
-
|
|
57
|
-
### Example
|
|
58
|
-
> "
|
|
59
|
-
|
|
60
|
-
→
|
|
1
|
+
# LiveDoc Vitest Skill — Routing Examples
|
|
2
|
+
|
|
3
|
+
## Positive routing (USE this skill)
|
|
4
|
+
|
|
5
|
+
### Example 1: Create a new BDD feature spec
|
|
6
|
+
> "Create a test for the shopping cart checkout flow"
|
|
7
|
+
|
|
8
|
+
→ This involves writing a `.Spec.ts` file using `feature`, `scenario`, `given`/`when`/`then` from `@swedevtools/livedoc-vitest`.
|
|
9
|
+
|
|
10
|
+
### Example 2: Add a scenario outline with examples
|
|
11
|
+
> "Add data-driven tests for email validation"
|
|
12
|
+
|
|
13
|
+
→ This involves using `scenarioOutline` or `ruleOutline` with an Examples table and `ctx.example`.
|
|
14
|
+
|
|
15
|
+
### Example 3: Fix value extraction in a step
|
|
16
|
+
> "The step says '500' but the test uses 200 — fix the value drift"
|
|
17
|
+
|
|
18
|
+
→ This involves replacing hardcoded values with `ctx.step.values[0]` or `ctx.step.params`.
|
|
19
|
+
|
|
20
|
+
### Example 4: Convert a plain vitest test to LiveDoc specification pattern
|
|
21
|
+
> "Rewrite these unit tests as a LiveDoc specification with rules"
|
|
22
|
+
|
|
23
|
+
→ This involves using `specification` and `rule`/`ruleOutline` from `@swedevtools/livedoc-vitest`.
|
|
24
|
+
|
|
25
|
+
### Example 5: Modify an existing spec file
|
|
26
|
+
> "Add a new scenario to UserAuth.Spec.ts for password reset"
|
|
27
|
+
|
|
28
|
+
→ This involves editing an existing `.Spec.ts` file using the correct LiveDoc patterns.
|
|
29
|
+
|
|
30
|
+
### Example 6: Write a browser test with Playwright
|
|
31
|
+
> "Write a Playwright test that checks the viewer homepage loads correctly"
|
|
32
|
+
|
|
33
|
+
→ Read `resources/web-testing.md` to confirm a real browser is required, then use `useBrowser` and `screenshot` from `@swedevtools/livedoc-vitest/playwright`. Assert behavior before attaching evidence.
|
|
34
|
+
|
|
35
|
+
### Example 7: Verify responsive browser geometry
|
|
36
|
+
> "Verify that the mobile action exposes at least a 44px touch target"
|
|
37
|
+
|
|
38
|
+
→ Use a real browser and measure rendered geometry. A jsdom assertion or CSS class check cannot observe this claim.
|
|
39
|
+
|
|
40
|
+
### Example 8: Validate an incremental change by tag
|
|
41
|
+
> "Run only the checkout and pricing behavior and patch the Viewer"
|
|
42
|
+
|
|
43
|
+
→ Read `resources/partial-testing.md`. Select `@checkout` and `@pricing`, publish the invocation as `partial`, and preserve the latest full baseline.
|
|
44
|
+
|
|
45
|
+
## Negative routing (DO NOT use this skill)
|
|
46
|
+
|
|
47
|
+
### Example 1: Writing a C# xUnit test
|
|
48
|
+
> "Create a test for the shipping calculator in C#"
|
|
49
|
+
|
|
50
|
+
→ Use the `livedoc-xunit` skill instead. This skill is TypeScript-only.
|
|
51
|
+
|
|
52
|
+
### Example 2: Building UI components
|
|
53
|
+
> "Create a React component for the test results viewer"
|
|
54
|
+
|
|
55
|
+
→ This is UI work, not test authoring. Use the `frontend-design` skill instead.
|
|
56
|
+
|
|
57
|
+
### Example 3: Plain vitest without LiveDoc
|
|
58
|
+
> "Write a vitest test for this utility function using describe/it"
|
|
59
|
+
|
|
60
|
+
→ This skill is for LiveDoc BDD/Specification patterns. Plain vitest tests don't need it.
|
|
61
|
+
|
|
62
|
+
### Example 4: Fixing build or config issues
|
|
63
|
+
> "The vitest config won't load, fix it"
|
|
64
|
+
|
|
65
|
+
→ This is build infrastructure, not test authoring. Handle directly without this skill.
|
|
66
|
+
|
|
67
|
+
### Example 5: Installing AI skills or generating static reports
|
|
68
|
+
> "Install the LiveDoc AI skill for my team" or "Generate a static HTML report"
|
|
69
|
+
|
|
70
|
+
→ These are setup/ops tasks. Run `npx livedoc-vitest-setup` for skills or `npx livedoc-viewer export -i results.json` for reports. Not test authoring.
|
|
71
|
+
|
|
72
|
+
### Example 6: Converting every low-level test
|
|
73
|
+
> "Convert the entire Vitest suite to LiveDoc"
|
|
74
|
+
|
|
75
|
+
→ Do not convert tests mechanically. Apply the two-question litmus in `resources/test-strategy.md` and keep tests without lasting documentation value in native Vitest.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# LiveDoc Test Anti-Patterns
|
|
2
|
+
|
|
3
|
+
Use this catalogue during review. These patterns are warnings, not blind syntax
|
|
4
|
+
bans; judge whether the assertion protects an implementation-independent promise.
|
|
5
|
+
|
|
6
|
+
| Anti-pattern | Symptom | Correction |
|
|
7
|
+
| --- | --- | --- |
|
|
8
|
+
| Class-name proxy | `toHaveClass('h-7')` stands in for size or layout | Measure the promise in a browser |
|
|
9
|
+
| Literal against itself | `expect(value).toBe(value)` | Derive expected and actual independently |
|
|
10
|
+
| Provably constant assertion | Algebra reduces to an unconditional truth | Use a defect-sensitive bound or oracle |
|
|
11
|
+
| Null-tolerant helper | Missing element returns success | Treat missing required subjects as failure |
|
|
12
|
+
| Guard-clause green | `if (!subject) return` skips the assertion | Assert presence before behavior |
|
|
13
|
+
| Filtered failure array | Known categories are removed before asserting empty | Classify failures explicitly; fail unknown categories |
|
|
14
|
+
| Implementation title | Step names classes, helpers, or internal flags | Name user-visible behavior or technical contract |
|
|
15
|
+
| Development-history title | Names rounds, team members, or retired behavior | State the current requirement |
|
|
16
|
+
| Multi-case loop | Many meaningful combinations fail as one row | Use an outline with one row per claim |
|
|
17
|
+
| Secret in documentation | Credential-shaped values enter titles, logs, or attachments | Use safe placeholders and absence assertions |
|
|
18
|
+
| Screenshot-only proof | Image is attached with no behavioral assertion | Assert first, attach evidence second |
|
|
19
|
+
| Fixed-wait race | Test sleeps and hopes state is ready | Use fake clocks, deferred promises, or readiness signals |
|