@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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @swedevtools/livedoc-vitest Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the LiveDoc Vitest SDK are documented in this file.
|
|
4
|
+
|
|
5
|
+
Use the `[next release]` section for changes that have not yet been promoted into a named package release, including temporary `0.0.0.x` builds.
|
|
6
|
+
|
|
7
|
+
## [next release]
|
|
8
|
+
|
|
9
|
+
## [0.3.0] - 2026-08-29
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added explicit full and partial Viewer publishing so focused development runs preserve the latest full test picture.
|
|
14
|
+
- Added optional Vitest coverage evidence from the in-memory coverage map, with JSON summary and LCOV artifact fallbacks.
|
|
15
|
+
- Added configurable coverage thresholds for lines, branches, functions, and statements; threshold misses are Viewer warnings and do not change test status.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Changed package exports to ESM-only because Vitest 4 cannot be loaded through CommonJS `require()`.
|
|
20
|
+
- Reorganized SDK tests into capability-focused sections so the suite doubles as clearer living documentation.
|
|
21
|
+
- Expanded the packaged AI skill with boundary-first test selection, false-green checks, rule-violation self-correction, web-runtime guidance, tag-scoped partial runs, LiveDoc-specific anti-patterns, and a consent-gated workflow for reporting verified LiveDoc framework defects upstream.
|
|
22
|
+
- Added OpenAI Codex and comma-separated multi-tool selection to the repository-local AI skill installer.
|
|
23
|
+
- Set the default published project name to `livedoc` so multiple projects are easier to distinguish in the viewer.
|
|
24
|
+
- Improved viewer autodiscovery by probing the local viewer when the temporary server metadata file is unavailable.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Fixed invalid nested LiveDoc declarations so feature, scenario, outline, background, specification, and rule nesting fails explicitly instead of silently dropping executable coverage.
|
|
29
|
+
- Fixed dynamic execution resets so each run retains LiveDoc's recommended default rule configuration without leaking caller overrides.
|
|
30
|
+
- Fixed the optional `@swedevtools/livedoc-server` peer range so the Vitest SDK accepts the companion `0.3.0` server release.
|
|
31
|
+
- Corrected the Vitest peer range to the tested `>=4.0.16 <5` contract instead of claiming unsupported Vitest 1-3 compatibility.
|
|
32
|
+
- Fixed specification tag rendering and serialization, including slash-style tags such as `@name/name`.
|
|
33
|
+
- Fixed LiveDoc filtering output so filtered tests are omitted from viewer/export results instead of appearing as pending or skipped.
|
|
34
|
+
- Fixed Viewer publication so coverage context, artifact paths, and run type flow through auto-discovered and explicitly configured reporters.
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014 dotnetprofessional
|
|
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
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 dotnetprofessional
|
|
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
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,95 +1,160 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# @swedevtools/livedoc-vitest
|
|
4
|
-
|
|
5
|
-
### Turn your tests into living documentation
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@swedevtools/livedoc-vitest)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
9
|
-
|
|
10
|
-
**Write tests in Gherkin. Get documentation that never goes stale.**
|
|
11
|
-
|
|
12
|
-
📖 **[Full Documentation →](https://livedoc.swedevtools.com/vitest/learn/getting-started)**
|
|
13
|
-
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## What is LiveDoc?
|
|
19
|
-
|
|
20
|
-
LiveDoc brings Behavior-Driven Development to Vitest with full Gherkin syntax — **Feature / Scenario / Given / When / Then**, **Specification / Rule**, **Scenario Outlines**, **Tags & Filtering**, and **beautiful reports**.
|
|
21
|
-
|
|
22
|
-
## Quick Start
|
|
23
|
-
|
|
24
|
-
### Install
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install --save-dev vitest @swedevtools/livedoc-vitest
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
###
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# @swedevtools/livedoc-vitest
|
|
4
|
+
|
|
5
|
+
### Turn your tests into living documentation
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@swedevtools/livedoc-vitest)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
**Write tests in Gherkin. Get documentation that never goes stale.**
|
|
11
|
+
|
|
12
|
+
📖 **[Full Documentation →](https://livedoc.swedevtools.com/vitest/learn/getting-started)**
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What is LiveDoc?
|
|
19
|
+
|
|
20
|
+
LiveDoc brings Behavior-Driven Development to Vitest with full Gherkin syntax — **Feature / Scenario / Given / When / Then**, **Specification / Rule**, **Scenario Outlines**, **Tags & Filtering**, and **beautiful reports**.
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save-dev vitest@^4.0.16 @swedevtools/livedoc-vitest
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Fastest Setup: Point Your AI at the Bootstrap URL
|
|
31
|
+
|
|
32
|
+
Tell your assistant:
|
|
33
|
+
|
|
34
|
+
> Read https://livedoc.swedevtools.com/ai/setup.md and configure this Vitest
|
|
35
|
+
> project for LiveDoc. Inspect it first, ask me one configuration question at a
|
|
36
|
+
> time, and wait for approval before making changes.
|
|
37
|
+
|
|
38
|
+
No LiveDoc package or skill needs to be installed first.
|
|
39
|
+
[AI project setup →](https://livedoc.swedevtools.com/guides/ai-project-setup)
|
|
40
|
+
|
|
41
|
+
AI setup installs version-matched skills inside the repository for every
|
|
42
|
+
selected tool. Run `npx livedoc-vitest-setup --tool copilot,codex,claude` later
|
|
43
|
+
to refresh them or add another tool. It also adds `test:livedoc` and, when
|
|
44
|
+
coverage is enabled, `test:livedoc:coverage` package scripts.
|
|
45
|
+
|
|
46
|
+
### Create a spec
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
// tests/Calculator.Spec.ts
|
|
50
|
+
import { feature, scenario, given, when, Then as then, and } from '@swedevtools/livedoc-vitest';
|
|
51
|
+
|
|
52
|
+
feature("Calculator", () => {
|
|
53
|
+
scenario("Adding two numbers", () => {
|
|
54
|
+
let result = 0;
|
|
55
|
+
|
|
56
|
+
given("I have entered '50' into the calculator", (ctx) => {
|
|
57
|
+
result = ctx.step.values[0];
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
and("I have entered '70' into the calculator", (ctx) => {
|
|
61
|
+
result += ctx.step.values[0];
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
when("I press add", () => {
|
|
65
|
+
// Addition already happened above
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
then("the result should be '120'", (ctx) => {
|
|
69
|
+
expect(result).toBe(ctx.step.values[0]);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
> **Why `Then as then`?** ES modules treat `then` as a thenable indicator. We export `Then` (uppercase) and you alias it.
|
|
76
|
+
|
|
77
|
+
### Configure Vitest
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// vitest.config.ts
|
|
81
|
+
import { defineConfig } from 'vitest/config';
|
|
82
|
+
import { LiveDocSpecReporter } from '@swedevtools/livedoc-vitest/reporter';
|
|
83
|
+
|
|
84
|
+
export default defineConfig({
|
|
85
|
+
test: {
|
|
86
|
+
globals: true,
|
|
87
|
+
include: ['**/*.Spec.ts'],
|
|
88
|
+
reporters: [new LiveDocSpecReporter()],
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Run
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx vitest run
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Publish a focused partial run
|
|
100
|
+
|
|
101
|
+
After publishing one full baseline, mark an isolated development run as partial so the Viewer keeps the complete latest-known picture:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
LIVEDOC_RUN_TYPE=partial npx vitest run features/Login.Spec.ts
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
You can also set `publish.runType` or `LiveDocViewerReporter({ runType: 'partial' })` in configuration. Partial runs require a running LiveDoc server and a completed full baseline for the same project and environment. Direct JSON/static partial export is not supported; release and production exports should use a full run.
|
|
108
|
+
|
|
109
|
+
### Add coverage evidence
|
|
110
|
+
|
|
111
|
+
LiveDoc can attach Vitest coverage as optional run evidence. It does not change the test run status; threshold misses appear as warnings in the viewer.
|
|
112
|
+
|
|
113
|
+
Install the V8 provider on the same version as Vitest:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install --save-dev @vitest/coverage-v8
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
// vitest.config.ts
|
|
121
|
+
import { defineConfig } from 'vitest/config';
|
|
122
|
+
import { LiveDocSpecReporter } from '@swedevtools/livedoc-vitest/reporter';
|
|
123
|
+
|
|
124
|
+
export default defineConfig({
|
|
125
|
+
test: {
|
|
126
|
+
reporters: [
|
|
127
|
+
new LiveDocSpecReporter({
|
|
128
|
+
coverage: { enabled: true, thresholds: { lines: 80 } },
|
|
129
|
+
}),
|
|
130
|
+
],
|
|
131
|
+
coverage: {
|
|
132
|
+
enabled: true,
|
|
133
|
+
provider: 'v8',
|
|
134
|
+
reporter: ['text', 'html', 'json-summary'],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npx vitest run --coverage
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
LiveDoc consumes Vitest's in-memory coverage map before the run is published. It also auto-detects `coverage/coverage-summary.json` and `coverage/lcov.info` as fallbacks. For custom artifact paths, set `coverage.artifactPath` in the reporter or use `LIVEDOC_COVERAGE_PATH`.
|
|
145
|
+
|
|
146
|
+
See the [Code Coverage guide](https://livedoc.swedevtools.com/viewer/guides/code-coverage) for provider choices, thresholds, troubleshooting, and the Viewer module hierarchy.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Documentation
|
|
151
|
+
|
|
152
|
+
📖 **[Full documentation at livedoc.swedevtools.com →](https://livedoc.swedevtools.com/vitest/learn/getting-started)**
|
|
153
|
+
|
|
154
|
+
Covers getting started, BDD & Specification patterns, data extraction, scenario outlines, tags & filtering, reporters, viewer integration, CI/CD, troubleshooting, and more.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT
|
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import { Attachment } from '@swedevtools/livedoc-schema';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Global type definitions for LiveDoc-Vitest
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
type DataTableRow = any[] | { [key: string]: any };
|
|
8
|
-
|
|
9
|
-
interface LiveDocMetaTable {
|
|
10
|
-
name: string;
|
|
11
|
-
description: string;
|
|
12
|
-
dataTable: DataTableRow[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface LiveDocStepTaskMeta {
|
|
16
|
-
kind: "step";
|
|
17
|
-
step: {
|
|
18
|
-
rawTitle: string;
|
|
19
|
-
type: string;
|
|
20
|
-
};
|
|
21
|
-
scenarioOutline?: {
|
|
22
|
-
title?: string;
|
|
23
|
-
description: string;
|
|
24
|
-
tables: LiveDocMetaTable[];
|
|
25
|
-
tags: string[];
|
|
26
|
-
example: {
|
|
27
|
-
sequence: number;
|
|
28
|
-
values: Record<string, unknown>;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface LiveDocRuleExampleTaskMeta {
|
|
34
|
-
kind: "ruleExample";
|
|
35
|
-
ruleOutline: {
|
|
36
|
-
title: string;
|
|
37
|
-
description: string;
|
|
38
|
-
tables: LiveDocMetaTable[];
|
|
39
|
-
tags: string[];
|
|
40
|
-
example: {
|
|
41
|
-
sequence: number;
|
|
42
|
-
values: Record<string, unknown>;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
interface LiveDocRuleTaskMeta {
|
|
48
|
-
kind: "rule";
|
|
49
|
-
rule: {
|
|
50
|
-
title: string;
|
|
51
|
-
description: string;
|
|
52
|
-
tags: string[];
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
type LiveDocTaskMeta = LiveDocStepTaskMeta | LiveDocRuleExampleTaskMeta | LiveDocRuleTaskMeta;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Extend Vitest's TaskMeta to include LiveDoc context
|
|
60
|
-
*/
|
|
61
|
-
declare module "@vitest/runner" {
|
|
62
|
-
interface TaskMeta {
|
|
63
|
-
livedoc?: LiveDocTaskMeta;
|
|
64
|
-
}
|
|
3
|
+
/**
|
|
4
|
+
* Global type definitions for LiveDoc-Vitest
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
type DataTableRow = any[] | { [key: string]: any };
|
|
8
|
+
|
|
9
|
+
interface LiveDocMetaTable {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
dataTable: DataTableRow[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface LiveDocStepTaskMeta {
|
|
16
|
+
kind: "step";
|
|
17
|
+
step: {
|
|
18
|
+
rawTitle: string;
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
scenarioOutline?: {
|
|
22
|
+
title?: string;
|
|
23
|
+
description: string;
|
|
24
|
+
tables: LiveDocMetaTable[];
|
|
25
|
+
tags: string[];
|
|
26
|
+
example: {
|
|
27
|
+
sequence: number;
|
|
28
|
+
values: Record<string, unknown>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface LiveDocRuleExampleTaskMeta {
|
|
34
|
+
kind: "ruleExample";
|
|
35
|
+
ruleOutline: {
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
tables: LiveDocMetaTable[];
|
|
39
|
+
tags: string[];
|
|
40
|
+
example: {
|
|
41
|
+
sequence: number;
|
|
42
|
+
values: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LiveDocRuleTaskMeta {
|
|
48
|
+
kind: "rule";
|
|
49
|
+
rule: {
|
|
50
|
+
title: string;
|
|
51
|
+
description: string;
|
|
52
|
+
tags: string[];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type LiveDocTaskMeta = LiveDocStepTaskMeta | LiveDocRuleExampleTaskMeta | LiveDocRuleTaskMeta;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Extend Vitest's TaskMeta to include LiveDoc context
|
|
60
|
+
*/
|
|
61
|
+
declare module "@vitest/runner" {
|
|
62
|
+
interface TaskMeta {
|
|
63
|
+
livedoc?: LiveDocTaskMeta;
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
package/dist/globals.d.ts
CHANGED
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import { F as FeatureContext, S as ScenarioContext, a as StepContext, B as BackgroundContext, b as SpecificationContext, R as RuleContext } from './RuleContext-
|
|
1
|
+
import { F as FeatureContext, S as ScenarioContext, a as StepContext, B as BackgroundContext, b as SpecificationContext, R as RuleContext } from './RuleContext-DQ8o_n1D.js';
|
|
2
2
|
import '@swedevtools/livedoc-schema';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* The context object passed to all LiveDoc test functions.
|
|
6
|
-
* Provides access to feature, scenario, step, example, and background contexts.
|
|
7
|
-
*/
|
|
8
|
-
interface LiveDocTestContext {
|
|
9
|
-
/** Framework metadata about the current feature */
|
|
10
|
-
feature?: FeatureContext;
|
|
11
|
-
/** Framework metadata about the current scenario */
|
|
12
|
-
scenario?: ScenarioContext;
|
|
13
|
-
/** Framework metadata about the current step */
|
|
14
|
-
step?: StepContext;
|
|
15
|
-
/** Framework metadata about the current scenario outline example */
|
|
16
|
-
example?: ScenarioContext;
|
|
17
|
-
/** Framework metadata about the background */
|
|
18
|
-
background?: BackgroundContext;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The context object passed to Specification pattern test functions.
|
|
23
|
-
*/
|
|
24
|
-
interface SpecificationTestContext {
|
|
25
|
-
/** Framework metadata about the current specification */
|
|
26
|
-
specification?: SpecificationContext;
|
|
27
|
-
/** Framework metadata about the current rule */
|
|
28
|
-
rule?: RuleContext;
|
|
29
|
-
/** Example data for rule outlines */
|
|
30
|
-
example?: Record<string, any>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
declare global {
|
|
34
|
-
/**
|
|
35
|
-
* Define a Gherkin feature
|
|
36
|
-
*/
|
|
37
|
-
function feature(title: string, fn: (ctx: LiveDocTestContext) => void): void;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Define a scenario within a feature
|
|
41
|
-
*/
|
|
42
|
-
function scenario(title: string, fn: (ctx: LiveDocTestContext) => void | Promise<void>): void;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Define a scenario outline (data-driven test)
|
|
46
|
-
* Examples are extracted from the title string by the parser
|
|
47
|
-
*/
|
|
48
|
-
function scenarioOutline(title: string, fn: (ctx: LiveDocTestContext) => void): void;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Define background steps that run before each scenario
|
|
52
|
-
*/
|
|
53
|
-
function background(title: string, fn: (ctx: LiveDocTestContext & {
|
|
54
|
-
afterBackground: (fn: () => void | Promise<void>) => void;
|
|
55
|
-
}) => void): void;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Define a given step (precondition)
|
|
59
|
-
*/
|
|
60
|
-
function given(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Define a when step (action)
|
|
64
|
-
*/
|
|
65
|
-
function when(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Define a then step (assertion)
|
|
69
|
-
* Available as lowercase global when using globals mode.
|
|
70
|
-
*/
|
|
71
|
-
function then(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Define an and step (continuation)
|
|
75
|
-
*/
|
|
76
|
-
function and(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Define a but step (continuation with contrast)
|
|
80
|
-
*/
|
|
81
|
-
function but(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
82
|
-
|
|
83
|
-
// ============================================
|
|
84
|
-
// Specification Pattern Globals
|
|
85
|
-
// ============================================
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Define a specification (container for rules)
|
|
89
|
-
*/
|
|
90
|
-
function specification(title: string, fn: (ctx: SpecificationTestContext) => void): void;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Define a rule within a specification
|
|
94
|
-
*/
|
|
95
|
-
function rule(title: string, fn: (ctx: SpecificationTestContext) => void | Promise<void>): void;
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Define a rule outline (data-driven rules)
|
|
99
|
-
* Examples are extracted from the title string by the parser
|
|
100
|
-
*/
|
|
101
|
-
function ruleOutline(title: string, fn: (ctx: SpecificationTestContext) => void | Promise<void>): void;
|
|
4
|
+
/**
|
|
5
|
+
* The context object passed to all LiveDoc test functions.
|
|
6
|
+
* Provides access to feature, scenario, step, example, and background contexts.
|
|
7
|
+
*/
|
|
8
|
+
interface LiveDocTestContext {
|
|
9
|
+
/** Framework metadata about the current feature */
|
|
10
|
+
feature?: FeatureContext;
|
|
11
|
+
/** Framework metadata about the current scenario */
|
|
12
|
+
scenario?: ScenarioContext;
|
|
13
|
+
/** Framework metadata about the current step */
|
|
14
|
+
step?: StepContext;
|
|
15
|
+
/** Framework metadata about the current scenario outline example */
|
|
16
|
+
example?: ScenarioContext;
|
|
17
|
+
/** Framework metadata about the background */
|
|
18
|
+
background?: BackgroundContext;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The context object passed to Specification pattern test functions.
|
|
23
|
+
*/
|
|
24
|
+
interface SpecificationTestContext {
|
|
25
|
+
/** Framework metadata about the current specification */
|
|
26
|
+
specification?: SpecificationContext;
|
|
27
|
+
/** Framework metadata about the current rule */
|
|
28
|
+
rule?: RuleContext;
|
|
29
|
+
/** Example data for rule outlines */
|
|
30
|
+
example?: Record<string, any>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare global {
|
|
34
|
+
/**
|
|
35
|
+
* Define a Gherkin feature
|
|
36
|
+
*/
|
|
37
|
+
function feature(title: string, fn: (ctx: LiveDocTestContext) => void): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Define a scenario within a feature
|
|
41
|
+
*/
|
|
42
|
+
function scenario(title: string, fn: (ctx: LiveDocTestContext) => void | Promise<void>): void;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Define a scenario outline (data-driven test)
|
|
46
|
+
* Examples are extracted from the title string by the parser
|
|
47
|
+
*/
|
|
48
|
+
function scenarioOutline(title: string, fn: (ctx: LiveDocTestContext) => void): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Define background steps that run before each scenario
|
|
52
|
+
*/
|
|
53
|
+
function background(title: string, fn: (ctx: LiveDocTestContext & {
|
|
54
|
+
afterBackground: (fn: () => void | Promise<void>) => void;
|
|
55
|
+
}) => void): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Define a given step (precondition)
|
|
59
|
+
*/
|
|
60
|
+
function given(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Define a when step (action)
|
|
64
|
+
*/
|
|
65
|
+
function when(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Define a then step (assertion)
|
|
69
|
+
* Available as lowercase global when using globals mode.
|
|
70
|
+
*/
|
|
71
|
+
function then(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Define an and step (continuation)
|
|
75
|
+
*/
|
|
76
|
+
function and(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Define a but step (continuation with contrast)
|
|
80
|
+
*/
|
|
81
|
+
function but(title: string, fn?: (ctx: LiveDocTestContext) => void | Promise<void>, passedParam?: object | Function): void;
|
|
82
|
+
|
|
83
|
+
// ============================================
|
|
84
|
+
// Specification Pattern Globals
|
|
85
|
+
// ============================================
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Define a specification (container for rules)
|
|
89
|
+
*/
|
|
90
|
+
function specification(title: string, fn: (ctx: SpecificationTestContext) => void): void;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Define a rule within a specification
|
|
94
|
+
*/
|
|
95
|
+
function rule(title: string, fn: (ctx: SpecificationTestContext) => void | Promise<void>): void;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Define a rule outline (data-driven rules)
|
|
99
|
+
* Examples are extracted from the title string by the parser
|
|
100
|
+
*/
|
|
101
|
+
function ruleOutline(title: string, fn: (ctx: SpecificationTestContext) => void | Promise<void>): void;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export type { LiveDocTestContext, SpecificationTestContext };
|