storybook-addon-vis 4.3.4 → 4.3.5
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 +10 -0
- package/llms.txt +16 -13
- package/package.json +2 -3
- package/readme.md +130 -15
- package/skills/review-image-snapshot-failures/README.md +1 -1
- package/skills/review-image-snapshot-failures/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# CHANGE LOG
|
|
2
2
|
|
|
3
|
+
## 4.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#962](https://github.com/repobuddy/visual-testing/pull/962) [`1847b46`](https://github.com/repobuddy/visual-testing/commit/1847b4685a93cc9f402e2944486202b6fc1a2ea3) Thanks [@unional](https://github.com/unional)! - Point the package readmes and the `review-image-snapshot-failures` skill at the documentation website.
|
|
8
|
+
Each readme now has install, minimal configuration, an example, a version compatibility table, and links to the matching website pages.
|
|
9
|
+
The skill links the "Reviewing Failures with Agents" page on the website instead of a source file.
|
|
10
|
+
- Updated dependencies [[`1847b46`](https://github.com/repobuddy/visual-testing/commit/1847b4685a93cc9f402e2944486202b6fc1a2ea3)]:
|
|
11
|
+
- vitest-plugin-vis@5.2.2
|
|
12
|
+
|
|
3
13
|
## 4.3.4
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/llms.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# storybook-addon-vis
|
|
2
2
|
|
|
3
|
-
> storybook-addon-vis: Storybook Vitest visual testing addon. Image snapshot testing for Vitest browser mode, with a Storybook integration.
|
|
3
|
+
> storybook-addon-vis: Storybook Vitest visual testing addon. Image snapshot testing for Vitest browser mode, with a Storybook integration. Documentation: https://repobuddy.github.io/visual-testing/
|
|
4
4
|
|
|
5
5
|
This file is generated by `packages/storybook-addon-vis/scripts/generate-llms-txt.mjs` from the packages' `exports` maps, their source, and the documentation pages. Do not edit it by hand; run `pnpm docs:llms` instead.
|
|
6
6
|
|
|
7
|
-
If an image snapshot test fails, read [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing
|
|
7
|
+
If an image snapshot test fails, read [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/) before opening any image. Without network access, read it from `node_modules/storybook-addon-vis/src/reviewing_failures_with_agents.mdx`.
|
|
8
8
|
|
|
9
9
|
Image snapshots are stored in the repository under `__vis__/`. Within it, `__baselines__` holds the expected images, `__results__` holds the images from the latest run, and `__diffs__` holds the diff images of failed comparisons. Next to each diff image, `<name>.review.png` is the review image of the changed regions and `<name>.regions.json` lists those regions.
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ Import from the entry points listed below, not from package internals. Documenta
|
|
|
12
12
|
|
|
13
13
|
## Start here
|
|
14
14
|
|
|
15
|
-
- [storybook-addon-vis: Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing
|
|
15
|
+
- [storybook-addon-vis: Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/): When an image snapshot fails, a coding agent often opens the baseline and the result and compares them.
|
|
16
16
|
|
|
17
17
|
## Packages
|
|
18
18
|
|
|
@@ -20,14 +20,18 @@ Import from the entry points listed below, not from package internals. Documenta
|
|
|
20
20
|
|
|
21
21
|
## Documentation
|
|
22
22
|
|
|
23
|
-
- [storybook-addon-vis:
|
|
24
|
-
- [storybook-addon-vis:
|
|
25
|
-
- [storybook-addon-vis:
|
|
26
|
-
- [storybook-addon-vis:
|
|
27
|
-
- [storybook-addon-vis:
|
|
28
|
-
- [storybook-addon-vis:
|
|
29
|
-
- [
|
|
30
|
-
- [
|
|
23
|
+
- [storybook-addon-vis: Automatic snapshots](https://repobuddy.github.io/visual-testing/addon/automatic-snapshots/): Take an image snapshot of every story without writing test code.
|
|
24
|
+
- [storybook-addon-vis: Install](https://repobuddy.github.io/visual-testing/addon/install/): Install storybook-addon-vis and its peer dependencies.
|
|
25
|
+
- [storybook-addon-vis: Manual snapshots](https://repobuddy.github.io/visual-testing/addon/manual-snapshots/): Take snapshots in a play function, check that one exists, and use the Chrome DevTools Protocol.
|
|
26
|
+
- [storybook-addon-vis: Releases/Migrating to 1.0](https://repobuddy.github.io/visual-testing/releases/migrate-to-1/): storybook-addon-vis 1.0 has made some major improvements over the previous version.
|
|
27
|
+
- [storybook-addon-vis: Releases/Migrating to 3.0](https://repobuddy.github.io/visual-testing/releases/migrate-to-3/): storybook-addon-vis 3.0.0 supports Storybook 10.
|
|
28
|
+
- [storybook-addon-vis: Setup](https://repobuddy.github.io/visual-testing/addon/setup/): Configure Storybook, Vitest, TypeScript and .gitignore for storybook-addon-vis. Documents: cdp, defineAutoSnapshotParam, hasImageSnapshot, page, visAnnotations, storybookVis, vis.
|
|
29
|
+
- [storybook-addon-vis: Troubleshooting](https://repobuddy.github.io/visual-testing/addon/troubleshooting/): Fix common installation and runtime problems.
|
|
30
|
+
- [storybook-addon-vis: node](https://repobuddy.github.io/visual-testing/reference/addon/node/): `storybook-addon-vis/node` provides functionality to configure the Storybook Visual Testing addon in the `.storybook/main.ts` file.
|
|
31
|
+
- [storybook-addon-vis: node/defineStorybookVis](https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis/): A helper function to configure the Storybook Visual Testing addon in `.storybook/main.ts`. Documents: defineStorybookVis.
|
|
32
|
+
- [storybook-addon-vis: node/defineStorybookVisOptions](https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis-options/): A helper function to configure options for Storybook Visual Testing addon. Documents: defineStorybookVisOptions.
|
|
33
|
+
- [vitest-plugin-vis: auto snapshots/setAutoSnapshotOptions](https://repobuddy.github.io/visual-testing/reference/plugin/set-auto-snapshot-options/): A function to configure visual snapshot testing options for the current test or test suite. Documents: setAutoSnapshotOptions.
|
|
34
|
+
- [vitest-plugin-vis: config/trimCommonFolder](https://repobuddy.github.io/visual-testing/reference/plugin/config/trim-common-folder/): The `trimCommonFolder` function is a utility that removes common folder prefixes from file paths to generate cleaner snapshot sub-paths. Documents: trimCommonFolder.
|
|
31
35
|
|
|
32
36
|
## Entry points
|
|
33
37
|
|
|
@@ -41,8 +45,7 @@ Import from the entry points listed below, not from package internals. Documenta
|
|
|
41
45
|
|
|
42
46
|
## Optional
|
|
43
47
|
|
|
44
|
-
- [storybook-addon-vis: Changelog](https://repobuddy.github.io/visual-testing
|
|
48
|
+
- [storybook-addon-vis: Changelog](https://repobuddy.github.io/visual-testing/releases/changelog-addon/): Release history of storybook-addon-vis.
|
|
45
49
|
- [Generator](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/scripts/generate-llms-txt.mjs): Source of this file. Run it with `--gaps` to list the undocumented exports.
|
|
46
50
|
|
|
47
51
|
Documentation coverage: 11 of 34 distinct exported declarations are named on a documentation page; 6 carry a doc comment.
|
|
48
|
-
2 of the pages above are not published on the documentation site; they link to their source on GitHub.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.5",
|
|
4
4
|
"description": "Storybook Vitest visual testing addon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"image-snapshot",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"memoize": "^11.0.0",
|
|
70
70
|
"pathe": "^2.0.3",
|
|
71
71
|
"type-plus": "8.0.1",
|
|
72
|
-
"vitest-plugin-vis": "^5.2.
|
|
72
|
+
"vitest-plugin-vis": "^5.2.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@repobuddy/storybook": "^2.33.4",
|
|
@@ -157,7 +157,6 @@
|
|
|
157
157
|
"nuke": "rimraf node_modules",
|
|
158
158
|
"prerelease": "zx scripts/prepublish-checks.js",
|
|
159
159
|
"sb": "storybook dev -p 6006",
|
|
160
|
-
"sb:build": "cross-env NODE_ENV=production storybook build",
|
|
161
160
|
"t:n": "vitest run -c vitest.config.node.ts",
|
|
162
161
|
"t:pw": "vitest run -c vitest.config.playwright.ts",
|
|
163
162
|
"t:t": "tsc --noEmit",
|
package/readme.md
CHANGED
|
@@ -25,15 +25,6 @@ This add-on provides similar functionality to [`jest-image-snapshot`][jest-image
|
|
|
25
25
|
In addition, you can capture image snapshot manually,
|
|
26
26
|
and controls how the auto image snapshot(s) are taken.
|
|
27
27
|
|
|
28
|
-
> [!NOTE]
|
|
29
|
-
> [storybook-addon-vis] 3.0.0 supports Storybook 10.
|
|
30
|
-
>
|
|
31
|
-
> [storybook-addon-vis] 2.0.0 supports Storybook 9.
|
|
32
|
-
>
|
|
33
|
-
> For Storybook 8, please use 1.x.
|
|
34
|
-
>
|
|
35
|
-
> With **Storybook 10.3+**, `@storybook/addon-vitest` often applies project annotations for you. If you are **not** on CSF Next, you may need to **remove** `visAnnotations` from `setProjectAnnotations([...])` in `vitest.setup.ts` and register the same hooks from **`.storybook/preview.ts`** instead (for example via `definePreview({ addons: [addonVis(...)] })` or `export default { ...visAnnotations, ... }`). See the [Overview docs](https://repobuddy.github.io/visual-testing/?path=/docs/overview--docs#storybook-103-and-vitest-project-annotations) section **Storybook 10.3+ and Vitest project annotations**.
|
|
36
|
-
|
|
37
28
|
## Install
|
|
38
29
|
|
|
39
30
|
```sh
|
|
@@ -44,20 +35,144 @@ pnpm add --save-dev storybook-addon-vis
|
|
|
44
35
|
yarn add --save-dev storybook-addon-vis
|
|
45
36
|
```
|
|
46
37
|
|
|
47
|
-
|
|
38
|
+
This addon requires the [Storybook Vitest addon][storybook-vitest-addon] (`@storybook/addon-vitest`).
|
|
39
|
+
|
|
40
|
+
## Minimal configuration
|
|
41
|
+
|
|
42
|
+
Add `storybookVis()` to the Vitest plugins, and `defineStorybookVis()` to the Storybook addons.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// vitest.config.ts
|
|
46
|
+
import { join } from 'node:path'
|
|
47
|
+
import { storybookTest } from '@storybook/addon-vitest/vitest-plugin'
|
|
48
|
+
import { playwright } from '@vitest/browser-playwright'
|
|
49
|
+
import { storybookVis } from 'storybook-addon-vis/vitest-plugin'
|
|
50
|
+
import { defineConfig } from 'vitest/config'
|
|
51
|
+
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
plugins: [storybookTest({ configDir: join(import.meta.dirname, '.storybook') }), storybookVis()],
|
|
54
|
+
test: {
|
|
55
|
+
browser: {
|
|
56
|
+
enabled: true,
|
|
57
|
+
headless: true,
|
|
58
|
+
api: { allowWrite: true },
|
|
59
|
+
provider: playwright(),
|
|
60
|
+
instances: [{ browser: 'chromium', viewport: { width: 1280, height: 720 } }],
|
|
61
|
+
},
|
|
62
|
+
setupFiles: ['./.storybook/vitest.setup.ts'],
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
// .storybook/vitest.setup.ts
|
|
69
|
+
import { setProjectAnnotations } from '@storybook/react-vite'
|
|
70
|
+
import { vis, visAnnotations } from 'storybook-addon-vis/vitest-setup'
|
|
71
|
+
import { beforeAll } from 'vitest'
|
|
72
|
+
import * as projectAnnotations from './preview.tsx'
|
|
73
|
+
|
|
74
|
+
const annotations = setProjectAnnotations([visAnnotations, projectAnnotations])
|
|
75
|
+
|
|
76
|
+
beforeAll(annotations.beforeAll)
|
|
77
|
+
|
|
78
|
+
vis.setup()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
// .storybook/main.ts
|
|
83
|
+
import { defineStorybookVis } from 'storybook-addon-vis/node'
|
|
84
|
+
|
|
85
|
+
export default {
|
|
86
|
+
// ...
|
|
87
|
+
addons: ['@storybook/addon-vitest', defineStorybookVis()],
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Add `tags: ['snapshot']` to your preview (or to a single story) to take an automatic snapshot of each story.
|
|
92
|
+
Ignore the snapshot folders in `.gitignore` and add the `storybook-addon-vis/matcher` type to your `tsconfig.json`.
|
|
93
|
+
The [setup guide][docs_setup] covers these, CSF Next, and the details.
|
|
94
|
+
|
|
95
|
+
The files above are adapted from the `sb-csf-3` test case (`testcases/sb-csf-3` in the repository, `@storybook/react-vite` framework), with its a11y and docs addons left out.
|
|
96
|
+
|
|
97
|
+
## Example
|
|
98
|
+
|
|
99
|
+
A manual snapshot in a `play` function:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
// button.stories.tsx
|
|
103
|
+
import type { StoryObj } from '@storybook/react-vite'
|
|
104
|
+
import { expect } from 'storybook/test'
|
|
105
|
+
|
|
106
|
+
export default {
|
|
107
|
+
render: () => <div data-testid="subject">unit</div>,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const MatchingElement: StoryObj = {
|
|
111
|
+
async play({ canvas }) {
|
|
112
|
+
const element = canvas.getByTestId('subject')
|
|
113
|
+
await expect(element).toMatchImageSnapshot()
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This is the `MatchingElement` story of `src/client/expect/to_match_image_snapshot.stories.tsx`, whose matching spec (`to_match_image_snapshot.spec.tsx`) runs it with `composeStories`.
|
|
119
|
+
|
|
120
|
+
## Version compatibility
|
|
121
|
+
|
|
122
|
+
| `storybook-addon-vis` | Storybook | Vitest | Source |
|
|
123
|
+
| --------------------- | --------- | ------ | ------ |
|
|
124
|
+
| 4.x | `^10.1.10` (also `@storybook/addon-vitest` `^10.1.10`) | `^4` (also `@vitest/browser` `^4`) | `peerDependencies` in `package.json` |
|
|
125
|
+
| 3.x | 10 | not derivable (3.0.0 depends on `vitest-plugin-vis` 4.0.0, which updated to Vitest 4) | `CHANGELOG.md` 3.0.0 |
|
|
126
|
+
| 2.x | 9 | not derivable | `CHANGELOG.md` 2.0.0 ("Supports Storybook 9.0.0") |
|
|
127
|
+
| 1.x | 8 | not derivable | previous version of this readme ("For Storybook 8, please use 1.x"), not stated in `CHANGELOG.md` |
|
|
128
|
+
|
|
129
|
+
The minimum Storybook patch version of 1.x to 3.x is not derivable.
|
|
130
|
+
|
|
131
|
+
With **Storybook 10.3+**, `@storybook/addon-vitest` often applies project annotations for you.
|
|
132
|
+
If you are not on CSF Next, you may need to move `visAnnotations` from `setProjectAnnotations([...])` in `vitest.setup.ts` to `.storybook/preview.ts`.
|
|
133
|
+
See [Storybook 10.3+ and Vitest project annotations][docs_setup_10_3].
|
|
134
|
+
|
|
135
|
+
## Documentation
|
|
136
|
+
|
|
137
|
+
Full documentation is on the [documentation website][docs]:
|
|
138
|
+
|
|
139
|
+
- [Install][docs_install]
|
|
140
|
+
- [Setup][docs_setup]
|
|
141
|
+
- [Automatic snapshots][docs_auto]
|
|
142
|
+
- [Manual snapshots][docs_manual]
|
|
143
|
+
- [Troubleshooting][docs_troubleshooting]
|
|
144
|
+
- [Reference: `defineStorybookVis()`][docs_define]
|
|
145
|
+
- [Reference: `defineStorybookVisOptions()`][docs_define_options]
|
|
146
|
+
- [Migrating to 3.0][docs_migrate_3] and [Migrating to 1.0][docs_migrate_1]
|
|
147
|
+
- [Reviewing failures with agents][docs_agents]
|
|
148
|
+
|
|
149
|
+
For AI agents, [`llms.txt`](llms.txt) in this package lists the entry points and documentation pages.
|
|
150
|
+
The site-wide copy is at <https://repobuddy.github.io/visual-testing/llms.txt>.
|
|
48
151
|
|
|
49
152
|
[@storybook/experimental-addon-test]: https://www.npmjs.com/package/@storybook/experimental-addon-test
|
|
153
|
+
[docs]: https://repobuddy.github.io/visual-testing/
|
|
154
|
+
[docs_agents]: https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/
|
|
155
|
+
[docs_auto]: https://repobuddy.github.io/visual-testing/addon/automatic-snapshots/
|
|
156
|
+
[docs_define]: https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis/
|
|
157
|
+
[docs_define_options]: https://repobuddy.github.io/visual-testing/reference/addon/define-storybook-vis-options/
|
|
158
|
+
[docs_install]: https://repobuddy.github.io/visual-testing/addon/install/
|
|
159
|
+
[docs_manual]: https://repobuddy.github.io/visual-testing/addon/manual-snapshots/
|
|
160
|
+
[docs_migrate_1]: https://repobuddy.github.io/visual-testing/releases/migrate-to-1/
|
|
161
|
+
[docs_migrate_3]: https://repobuddy.github.io/visual-testing/releases/migrate-to-3/
|
|
162
|
+
[docs_setup]: https://repobuddy.github.io/visual-testing/addon/setup/
|
|
163
|
+
[docs_setup_10_3]: https://repobuddy.github.io/visual-testing/addon/setup/#storybook-103-and-vitest-project-annotations
|
|
164
|
+
[docs_troubleshooting]: https://repobuddy.github.io/visual-testing/addon/troubleshooting/
|
|
50
165
|
[downloads_image]: https://img.shields.io/npm/dm/storybook-addon-vis.svg?style=flat
|
|
51
|
-
[github_action_url]: https://github.com/repobuddy/
|
|
52
|
-
[github_release]: https://github.com/repobuddy/
|
|
166
|
+
[github_action_url]: https://github.com/repobuddy/visual-testing/actions/workflows/release.yml
|
|
167
|
+
[github_release]: https://github.com/repobuddy/visual-testing/actions/workflows/release.yml/badge.svg
|
|
53
168
|
[jest-image-snapshot]: https://github.com/americanexpress/jest-image-snapshot
|
|
54
169
|
[npm_image]: https://img.shields.io/npm/v/storybook-addon-vis.svg?style=flat
|
|
55
170
|
[npm_url]: https://npmjs.org/package/storybook-addon-vis
|
|
56
171
|
[portable-stories]: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest
|
|
57
172
|
[stories]: https://storybook.js.org/docs/writing-stories
|
|
58
|
-
[storybook-addon-vis]: https://github.com/repobuddy/storybook-addon-vis
|
|
59
|
-
[storybook-test-addon]: https://storybook.js.org/docs/writing-tests/
|
|
173
|
+
[storybook-addon-vis]: https://github.com/repobuddy/visual-testing/tree/main/packages/storybook-addon-vis
|
|
174
|
+
[storybook-test-addon]: https://storybook.js.org/docs/writing-tests/integrations/vitest-addon
|
|
175
|
+
[storybook-vitest-addon]: https://storybook.js.org/docs/writing-tests/integrations/vitest-addon
|
|
60
176
|
[storybook]: https://storybook.js.org
|
|
61
177
|
[vitest-browser-mode]: https://vitest.dev/guide/browser/
|
|
62
178
|
[vitest-plugin-vis]: https://www.npmjs.com/package/vitest-plugin-vis
|
|
63
|
-
[vitest]: https://vitest.dev/
|
|
@@ -15,4 +15,4 @@ An agent loads it when a visual test fails with a `Snapshot ... mismatched` erro
|
|
|
15
15
|
|
|
16
16
|
## Install
|
|
17
17
|
|
|
18
|
-
It ships as a plugin in both the `vitest-plugin-vis` and `storybook-addon-vis` npm packages (`plugin.json` and `skills/` in the package), identical in each. The measured token costs are on the
|
|
18
|
+
It ships as a plugin in both the `vitest-plugin-vis` and `storybook-addon-vis` npm packages (`plugin.json` and `skills/` in the package), identical in each. The measured token costs are on the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/) page.
|
|
@@ -27,7 +27,7 @@ Snapshots live under `__vis__/`: `__baselines__` is expected, `__results__` is t
|
|
|
27
27
|
- Same content, only the edges of text or shapes differ: rendering drift (fonts, operating system, browser). Report it; do not update the baseline.
|
|
28
28
|
- Anything else is a regression. Fix it or report it.
|
|
29
29
|
|
|
30
|
-
Full explanation and measured token costs: the
|
|
30
|
+
Full explanation and measured token costs: the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/guides/reviewing-failures-with-agents/) page. The `llms.txt` in the package links it and names the copy in `node_modules` to read without network access.
|
|
31
31
|
|
|
32
32
|
## Validate
|
|
33
33
|
|