@describe-me/vitest 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -92
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -1,108 +1,75 @@
|
|
|
1
1
|
# @describe-me/vitest
|
|
2
2
|
|
|
3
|
-
The Vitest
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
**Your tests are your stories.** The Vitest plugin, setup files and reporter of
|
|
4
|
+
describe-me: living component documentation generated from the Vitest tests
|
|
5
|
+
you already have.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**[Read the docs](https://grzehub.github.io/describe-me/)** · open the viewer
|
|
8
|
+
of the [browser-mode example](https://grzehub.github.io/describe-me/examples/react-browser/)
|
|
9
|
+
or the [jsdom example](https://grzehub.github.io/describe-me/examples/react-jsdom/)
|
|
10
|
+
· [Limitations](https://grzehub.github.io/describe-me/limitations.html)
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
describe-me captures the DOM after each step of a test and shows the result as
|
|
13
|
+
a browsable catalog. `describe` blocks become the sidebar, each `it` is a
|
|
14
|
+
story, and each step is a frame you can scrub through. Stories cannot rot,
|
|
15
|
+
because they are tests. If one drifts from the component, CI goes red.
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
One line in the Vitest config registers the setup file and the reporter, and
|
|
19
|
-
redirects the test library's `render` import to the recording adapter. The
|
|
20
|
-
plugin detects where the tests run:
|
|
21
|
-
|
|
22
|
-
- **Browser mode** (`test.browser.enabled`): redirects `vitest-browser-react`,
|
|
23
|
-
records a frame after every `Locator` action and keyboard-level `userEvent`.
|
|
24
|
-
- **DOM environments** such as jsdom (anything else): redirects
|
|
25
|
-
`@testing-library/react`, records a frame after every `fireEvent` and every
|
|
26
|
-
`@testing-library/user-event` call, turns on `test.css` so imported
|
|
27
|
-
stylesheets reach the snapshots, and sets `RTL_SKIP_AUTO_CLEANUP` so the
|
|
28
|
-
component is unmounted only after the closing frame. The setup file sets
|
|
29
|
-
React's `IS_REACT_ACT_ENVIRONMENT` where Testing Library would. With
|
|
30
|
-
`@testing-library/react`, it takes user-event frames without a wait. The
|
|
31
|
-
flag is off for the few waits that remain, which can still move an act
|
|
32
|
-
warning
|
|
33
|
-
([jsdom](https://grzehub.github.io/describe-me/environments.html#jsdom)). It
|
|
34
|
-
also works without user-event installed.
|
|
35
|
-
|
|
36
|
-
jsdom has no layout, so positioned popovers show in the top-left corner and
|
|
37
|
-
canvas stays blank
|
|
38
|
-
([Limitations in jsdom](https://grzehub.github.io/describe-me/environments.html#jsdom-limits)).
|
|
17
|
+
Status: prototype. React 18 and 19, Vitest 4 and 5 in browser mode or jsdom,
|
|
18
|
+
static snapshots.
|
|
39
19
|
|
|
40
|
-
|
|
41
|
-
import { describeMe } from '@describe-me/vitest/plugin'
|
|
20
|
+
## Which package do I need
|
|
42
21
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
22
|
+
| Package | What it is | Install it |
|
|
23
|
+
| --------------------- | -------------------------------------------------- | ----------------------- |
|
|
24
|
+
| `describe-me` | the viewer and the `describe-me` CLI | yes |
|
|
25
|
+
| `@describe-me/vitest` | the Vitest plugin, setup files and reporter (this) | yes |
|
|
26
|
+
| `@describe-me/react` | `render` functions that record frames | yes |
|
|
27
|
+
| `@describe-me/core` | the recorder and the manifest types | no, the others bring it |
|
|
50
28
|
|
|
51
|
-
|
|
52
|
-
export default defineConfig({
|
|
53
|
-
plugins: [react(), describeMe()],
|
|
54
|
-
test: { environment: 'jsdom' },
|
|
55
|
-
})
|
|
56
|
-
```
|
|
29
|
+
## Quick start
|
|
57
30
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
no interaction, no `step()`) costs no snapshot and is left out of the
|
|
62
|
-
manifest. `describeMe({ include, exclude })` chooses which test files are
|
|
63
|
-
recorded, with picomatch globs relative to the Vitest root. `exclude` wins.
|
|
64
|
-
Tests in other files still run, but record nothing. Leaving `include` out
|
|
65
|
-
records every test file. `include: []` records none and warns, while
|
|
66
|
-
`exclude: '**'` records none without a warning. The reporter takes the
|
|
67
|
-
same two options, but on its own it only filters the manifest: without the
|
|
68
|
-
plugin the setup file does not know them.
|
|
69
|
-
|
|
70
|
-
`describeMe({ previewHead })` takes HTML that the viewer adds to the start of
|
|
71
|
-
every frame's `<head>`, like Storybook's `preview-head.html`: typically the
|
|
72
|
-
font links that the app shell loads and tests never do. It never reaches the
|
|
73
|
-
test page, and the local files it links are copied into the output directory
|
|
74
|
-
([Fonts](https://grzehub.github.io/describe-me/styles-and-fonts.html#fonts) in the docs).
|
|
75
|
-
|
|
76
|
-
`describeMe({ renderFrame })` chooses when the render frame is taken:
|
|
77
|
-
`'eager'` (default) right after mount, `'lazy'` right before the next
|
|
78
|
-
interaction, or `{ pending: '<selector>' }` once a loader is gone. See
|
|
79
|
-
[Render frame timing](https://grzehub.github.io/describe-me/configuration.html#render-frame).
|
|
80
|
-
|
|
81
|
-
The plugin adds its reporter to the ones your config names. If it names
|
|
82
|
-
none, the reporter joins the ones Vitest picks on its own, such as `minimal`
|
|
83
|
-
for AI agents and `github-actions` in GitHub Actions.
|
|
84
|
-
|
|
85
|
-
The pieces can also be wired by hand. Tests then import from the adapter
|
|
86
|
-
themselves: `render` from `@describe-me/react` in browser mode, and `render`,
|
|
87
|
-
`fireEvent` and `cleanup` from `@describe-me/react/testing-library` in jsdom:
|
|
31
|
+
```sh
|
|
32
|
+
pnpm add -D describe-me @describe-me/vitest @describe-me/react
|
|
33
|
+
```
|
|
88
34
|
|
|
89
35
|
```ts
|
|
90
|
-
|
|
36
|
+
// vitest.config.ts
|
|
37
|
+
import { describeMe } from '@describe-me/vitest/plugin'
|
|
91
38
|
|
|
92
39
|
export default defineConfig({
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
setupFiles: ['@describe-me/vitest/setup-dom'],
|
|
96
|
-
reporters: ['default', new DescribeMeReporter()],
|
|
97
|
-
// jsdom only: keep imported CSS and leave unmounting to describe-me
|
|
98
|
-
css: true,
|
|
99
|
-
env: { RTL_SKIP_AUTO_CLEANUP: 'true' },
|
|
100
|
-
},
|
|
40
|
+
plugins: [react(), describeMe()],
|
|
41
|
+
test: { environment: 'jsdom' }, // or your browser-mode settings
|
|
101
42
|
})
|
|
102
43
|
```
|
|
103
44
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
45
|
+
Run your tests, then `describe-me dev` opens the viewer.
|
|
46
|
+
[Getting started](https://grzehub.github.io/describe-me/getting-started.html)
|
|
47
|
+
walks through both environments. Keep all describe-me packages on one version
|
|
48
|
+
([why](https://grzehub.github.io/describe-me/installation.html#lockstep)).
|
|
49
|
+
|
|
50
|
+
## This package
|
|
51
|
+
|
|
52
|
+
The plugin is the whole integration. It detects browser mode or a DOM
|
|
53
|
+
environment, registers the setup file and the reporter, and redirects your
|
|
54
|
+
test library's `render` to the recording one, so existing tests record frames
|
|
55
|
+
unchanged.
|
|
56
|
+
[What the plugin changes](https://grzehub.github.io/describe-me/configuration.html#plugin)
|
|
57
|
+
lists every change it makes to your config, and
|
|
58
|
+
[Options](https://grzehub.github.io/describe-me/configuration.html#options)
|
|
59
|
+
every option it takes.
|
|
60
|
+
|
|
61
|
+
| Entry point | What it holds |
|
|
62
|
+
| ------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
63
|
+
| `@describe-me/vitest/plugin` | [`describeMe()`](https://grzehub.github.io/describe-me/api.html#entry-vitest-plugin) |
|
|
64
|
+
| `@describe-me/vitest` | [`step()` and `recorder`](https://grzehub.github.io/describe-me/api.html#entry-vitest) |
|
|
65
|
+
| `@describe-me/vitest/setup` | [the browser-mode setup file](https://grzehub.github.io/describe-me/api.html#entry-vitest-setup) |
|
|
66
|
+
| `@describe-me/vitest/setup-dom` | [the jsdom setup file](https://grzehub.github.io/describe-me/api.html#entry-vitest-setup-dom) |
|
|
67
|
+
| `@describe-me/vitest/reporter` | [the reporter, to wire by hand](https://grzehub.github.io/describe-me/api.html#entry-vitest-reporter) |
|
|
68
|
+
|
|
69
|
+
`typescript` and `@testing-library/user-event` are optional peers. Without
|
|
70
|
+
TypeScript the docs have no props tables. user-event is needed only when your
|
|
71
|
+
jsdom tests use it.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@describe-me/vitest",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.4",
|
|
4
|
+
"description": "Living component documentation from your Vitest tests: the Vitest plugin, setup files and reporter of describe-me",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vitest",
|
|
7
|
+
"react",
|
|
7
8
|
"storybook",
|
|
9
|
+
"storybook alternative",
|
|
8
10
|
"component documentation",
|
|
9
|
-
"
|
|
11
|
+
"living documentation",
|
|
12
|
+
"jsdom",
|
|
10
13
|
"testing"
|
|
11
14
|
],
|
|
12
15
|
"license": "MIT",
|
|
@@ -60,13 +63,13 @@
|
|
|
60
63
|
"dependencies": {
|
|
61
64
|
"picomatch": "^4.0.3",
|
|
62
65
|
"std-env": "^4.0.0",
|
|
63
|
-
"@describe-me/core": "^0.5.
|
|
66
|
+
"@describe-me/core": "^0.5.4"
|
|
64
67
|
},
|
|
65
68
|
"peerDependencies": {
|
|
66
69
|
"vitest": "^4.0.0 || ^5.0.0",
|
|
67
70
|
"typescript": "^5.0.0 || ^6.0.0",
|
|
68
71
|
"@testing-library/user-event": "^14.0.0",
|
|
69
|
-
"describe-me": "^0.5.
|
|
72
|
+
"describe-me": "^0.5.4"
|
|
70
73
|
},
|
|
71
74
|
"peerDependenciesMeta": {
|
|
72
75
|
"typescript": {
|