storybook-addon-vis 4.4.0 → 4.5.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 +25 -0
- package/dist/exports/vitest-setup.d.mts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/vis_annotation-pQo0FcfJ.d.mts +9 -0
- package/dist/vis_annotation-pQo0FcfJ.d.mts.map +1 -0
- package/llms.txt +36 -14
- package/package.json +3 -3
- package/readme.md +8 -8
- package/skills/review-image-snapshot-failures/README.md +1 -1
- package/skills/review-image-snapshot-failures/SKILL.md +1 -1
- package/src/index.ts +2 -5
- package/src/overview.mdx +14 -0
- package/dist/vis_annotation-N0xbuXis.d.mts +0 -9
- package/dist/vis_annotation-N0xbuXis.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# CHANGE LOG
|
|
2
2
|
|
|
3
|
+
## 4.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1002](https://github.com/repobuddy/visual-testing/pull/1002) [`3dd963f`](https://github.com/repobuddy/visual-testing/commit/3dd963fdb902b0dfbecf3fccc9d562287e9ea583) Thanks [@unional](https://github.com/unional)! - Add an `animations` option (`'disabled' | 'allow'`, default `'allow'`) to `toMatchImageSnapshot()`, `page.toMatchImageSnapshot()`, `setAutoSnapshotOptions()` and `vis.setup()`. With `'disabled'`, finite CSS animations and transitions are finished and infinite ones are cancelled before the snapshot, so animated components give stable images with both the Playwright and WebdriverIO providers.
|
|
8
|
+
|
|
9
|
+
- [#1003](https://github.com/repobuddy/visual-testing/pull/1003) [`09440c3`](https://github.com/repobuddy/visual-testing/commit/09440c3d9a0a21c7fcc0535eb89c96b8d016ce45) Thanks [@unional](https://github.com/unional)! - Add a `mask` option to `toMatchImageSnapshot()` (both `expect(...)` and `page.`), `setAutoSnapshotOptions()` and `vis.setup({ auto })`. It takes selectors, locators or elements and paints them over before the snapshot is taken, so content that changes on every run does not fail the comparison. `maskColor` sets the color. It works with the Playwright and WebdriverIO providers.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#949](https://github.com/repobuddy/visual-testing/pull/949) [`a4ce784`](https://github.com/repobuddy/visual-testing/commit/a4ce78437d5ff697176b25002f411be2868346ef) Thanks [@dependabot](https://github.com/apps/dependabot)! - Update `glob` to v14.
|
|
14
|
+
|
|
15
|
+
- [#1005](https://github.com/repobuddy/visual-testing/pull/1005) [`3a7ed6e`](https://github.com/repobuddy/visual-testing/commit/3a7ed6e9c1621af94a8535517b6be000f5b44e3a) Thanks [@unional](https://github.com/unional)! - State on the Compare pages that masking is supported.
|
|
16
|
+
|
|
17
|
+
- [#993](https://github.com/repobuddy/visual-testing/pull/993) [`67ac628`](https://github.com/repobuddy/visual-testing/commit/67ac628e3d6f41cfc8fdfe77e6153180b9595062) Thanks [@unional](https://github.com/unional)! - List the new Vitest plugin guides, examples, troubleshooting and reference pages in `llms.txt`, and document more of the plugin's public API.
|
|
18
|
+
|
|
19
|
+
- [#992](https://github.com/repobuddy/visual-testing/pull/992) [`b427b9e`](https://github.com/repobuddy/visual-testing/commit/b427b9eb73f88ebaa6e6eeafdda618e971b9ad58) Thanks [@unional](https://github.com/unional)! - Document `addonVis`, `isSnapshotEnabled` and the preset entry in the overview page, and link the new addon guides from `llms.txt`.
|
|
20
|
+
|
|
21
|
+
- [#988](https://github.com/repobuddy/visual-testing/pull/988) [`42dc3dd`](https://github.com/repobuddy/visual-testing/commit/42dc3ddfa4b18e171ab1da832000fac5220de65b) Thanks [@unional](https://github.com/unional)! - Update the readme, `llms.txt` and `review-image-snapshot-failures` skill links to the new website page locations.
|
|
22
|
+
The old page URLs still redirect to the new ones.
|
|
23
|
+
|
|
24
|
+
- [#991](https://github.com/repobuddy/visual-testing/pull/991) [`06d72bf`](https://github.com/repobuddy/visual-testing/commit/06d72bfe7490723e77a75dbeb0d6bdea863468ca) Thanks [@unional](https://github.com/unional)! - List the new Visual testing concept pages of the website in `llms.txt`.
|
|
25
|
+
- Updated dependencies [[`a4ce784`](https://github.com/repobuddy/visual-testing/commit/a4ce78437d5ff697176b25002f411be2868346ef), [`3a7ed6e`](https://github.com/repobuddy/visual-testing/commit/3a7ed6e9c1621af94a8535517b6be000f5b44e3a), [`3dd963f`](https://github.com/repobuddy/visual-testing/commit/3dd963fdb902b0dfbecf3fccc9d562287e9ea583), [`09440c3`](https://github.com/repobuddy/visual-testing/commit/09440c3d9a0a21c7fcc0535eb89c96b8d016ce45), [`67ac628`](https://github.com/repobuddy/visual-testing/commit/67ac628e3d6f41cfc8fdfe77e6153180b9595062), [`42dc3dd`](https://github.com/repobuddy/visual-testing/commit/42dc3ddfa4b18e171ab1da832000fac5220de65b), [`06d72bf`](https://github.com/repobuddy/visual-testing/commit/06d72bfe7490723e77a75dbeb0d6bdea863468ca)]:
|
|
26
|
+
- vitest-plugin-vis@5.4.0
|
|
27
|
+
|
|
3
28
|
## 4.4.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../global_matcher_augment-B1plNA_9.mjs";
|
|
2
|
-
import { t as visAnnotations } from "../vis_annotation-
|
|
2
|
+
import { t as visAnnotations } from "../vis_annotation-pQo0FcfJ.mjs";
|
|
3
3
|
import { setAutoSnapshotOptions } from "vitest-plugin-vis";
|
|
4
4
|
import * as vitest_plugin_vis_setup_api0 from "vitest-plugin-vis/setup-api";
|
|
5
5
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./global_matcher_augment-B1plNA_9.mjs";
|
|
2
|
-
import { t as visAnnotations } from "./vis_annotation-
|
|
2
|
+
import { t as visAnnotations } from "./vis_annotation-pQo0FcfJ.mjs";
|
|
3
3
|
import * as storybook_internal_csf0 from "storybook/internal/csf";
|
|
4
4
|
import { ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotKeyOptions, ImageSnapshotKeyOptions as ImageSnapshotKeyOptions$1, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, PixelComparisonOptions, SsimComparisonOptions, ToMatchImageSnapshotOptions } from "vitest-plugin-vis/client-api";
|
|
5
5
|
import * as vitest_plugin_vis0 from "vitest-plugin-vis";
|
|
@@ -24,7 +24,7 @@ declare function hasImageSnapshot(options?: ImageSnapshotKeyOptions$1 | undefine
|
|
|
24
24
|
* Define snapshot parameter for auto snapshot.
|
|
25
25
|
*/
|
|
26
26
|
declare function defineAutoSnapshotParam<M extends ComparisonMethod>(snapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions): {
|
|
27
|
-
snapshot: ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & (M extends "ssim" ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions & vitest_plugin_vis0.ReviewImageOptions & {
|
|
27
|
+
snapshot: ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & (M extends "ssim" ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions & vitest_plugin_vis0.ReviewImageOptions & vitest_plugin_vis0.AnimationsOptions & vitest_plugin_vis0.MaskOptions & {
|
|
28
28
|
expectToFail?: boolean | undefined;
|
|
29
29
|
createMissingBaseline?: boolean | undefined;
|
|
30
30
|
} & ImageSnapshotSubjectOptions;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as commands, c as whenVitestProxyReady, i as cdp, l as isVitestBrowser, n as isSnapshotEnabled, o as getCurrentTest, r as toMatchImageSnapshot, s as page, t as visAnnotations } from "./vis_annotation-BHBO0X19.mjs";
|
|
2
2
|
import { definePreviewAddon } from "storybook/internal/csf";
|
|
3
3
|
import { expect } from "storybook/test";
|
|
4
|
-
import { autoSnapshotMatcher, hasImageSnapshotAction, setAutoSnapshotOptions, toTaskId } from "vitest-plugin-vis/client-api";
|
|
4
|
+
import { autoSnapshotMatcher, hasImageSnapshotAction, setAutoSnapshotOptions, toSuiteDefaults, toTaskId } from "vitest-plugin-vis/client-api";
|
|
5
5
|
|
|
6
6
|
export * from "vitest-plugin-vis"
|
|
7
7
|
|
|
@@ -45,7 +45,7 @@ var src_default = (options = { auto: false }) => {
|
|
|
45
45
|
if (!isVitestBrowser()) return;
|
|
46
46
|
await whenVitestProxyReady();
|
|
47
47
|
matcher = autoSnapshotMatcher(commands, expect);
|
|
48
|
-
const suiteDefaults = options
|
|
48
|
+
const suiteDefaults = toSuiteDefaults(options);
|
|
49
49
|
if (typeof options?.auto === "function") matcherFn = matcher.createMatcher({ auto: options.auto }, suiteDefaults);
|
|
50
50
|
else if (typeof options?.auto === "object") matcherFn = matcher.createMatcher(options.auto, suiteDefaults);
|
|
51
51
|
else matcherFn = matcher.createMatcher({ async auto() {} }, suiteDefaults);
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/index.ts"],"sourcesContent":["import { getCurrentTest } from './vitest_proxy.ts'\n\nexport const ctx = {\n\tgetCurrentTest,\n\t__test__reset() {\n\t\tctx.getCurrentTest = getCurrentTest\n\t},\n}\n","import { hasImageSnapshotAction, type ImageSnapshotKeyOptions, toTaskId } from 'vitest-plugin-vis/client-api'\nimport { ctx } from './ctx.ts'\nimport { commands } from './vitest_proxy.ts'\n\n/**\n * Check if the snapshot image exists.\n */\nexport function hasImageSnapshot(options?: ImageSnapshotKeyOptions | undefined) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) return false\n\n\treturn hasImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n} from 'vitest-plugin-vis/client-api'\n\n// This fix the inferred type cannot be named error\nexport type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n}\n\n/**\n * Define snapshot parameter for auto snapshot.\n */\nexport function defineAutoSnapshotParam<M extends ComparisonMethod>(\n\tsnapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions,\n) {\n\treturn { snapshot }\n}\n","// `storybook-addon-vis` provides code that can be used in test files.\nimport './shared/global_matcher_augment.ts'\n\nimport { definePreviewAddon } from 'storybook/internal/csf'\nimport { expect } from 'storybook/test'\nimport type { SetupVisOptions } from 'vitest-plugin-vis'\nimport { autoSnapshotMatcher, setAutoSnapshotOptions } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './client/expect/to_match_image_snapshot.ts'\nimport { isVitestBrowser } from './client/is_vitest_browser.ts'\nimport { cdp, commands, page, whenVitestProxyReady } from './client/vitest_proxy.ts'\nimport { visAnnotations } from './preview/vis_annotation.ts'\n\n// Register at module load time so it's available in Storybook dev mode.\n// (visAnnotations.beforeEach is only wired via vitest's setProjectAnnotations, not in dev mode)\nexpect.extend({ toMatchImageSnapshot })\n\nexport * from 'vitest-plugin-vis'\nexport * from './client/has_image_snapshot.ts'\nexport * from './client/storybook/param.ts'\nexport * from './client/storybook/tags.ts'\n\nexport { cdp, page, visAnnotations }\n\nexport default (options: SetupVisOptions<{ tags: string[] }> = { auto: false }) => {\n\tlet matcher: ReturnType<typeof autoSnapshotMatcher>\n\tlet matcherFn: () => Promise<void>\n\treturn definePreviewAddon({\n\t\ttags: options.auto === true ? ['snapshot'] : [],\n\t\tasync beforeAll() {\n\t\t\tif (!isVitestBrowser()) return\n\t\t\t// `page` and `getCurrentTest` come from a dynamic import; the hooks that\n\t\t\t// follow read them synchronously, so wait for it here (#835).\n\t\t\tawait whenVitestProxyReady()\n\t\t\tmatcher = autoSnapshotMatcher(commands, expect)\n\t\t\tconst suiteDefaults
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/client/ctx.ts","../src/client/has_image_snapshot.ts","../src/client/storybook/param.ts","../src/index.ts"],"sourcesContent":["import { getCurrentTest } from './vitest_proxy.ts'\n\nexport const ctx = {\n\tgetCurrentTest,\n\t__test__reset() {\n\t\tctx.getCurrentTest = getCurrentTest\n\t},\n}\n","import { hasImageSnapshotAction, type ImageSnapshotKeyOptions, toTaskId } from 'vitest-plugin-vis/client-api'\nimport { ctx } from './ctx.ts'\nimport { commands } from './vitest_proxy.ts'\n\n/**\n * Check if the snapshot image exists.\n */\nexport function hasImageSnapshot(options?: ImageSnapshotKeyOptions | undefined) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) return false\n\n\treturn hasImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n} from 'vitest-plugin-vis/client-api'\n\n// This fix the inferred type cannot be named error\nexport type {\n\tComparisonMethod,\n\tFailureThresholdOptions,\n\tImageSnapshotCompareOptions,\n\tImageSnapshotKeyOptions,\n\tImageSnapshotSubjectOptions,\n\tImageSnapshotTimeoutOptions,\n\tPixelComparisonOptions,\n\tSsimComparisonOptions,\n\tToMatchImageSnapshotOptions,\n}\n\n/**\n * Define snapshot parameter for auto snapshot.\n */\nexport function defineAutoSnapshotParam<M extends ComparisonMethod>(\n\tsnapshot: ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions,\n) {\n\treturn { snapshot }\n}\n","// `storybook-addon-vis` provides code that can be used in test files.\nimport './shared/global_matcher_augment.ts'\n\nimport { definePreviewAddon } from 'storybook/internal/csf'\nimport { expect } from 'storybook/test'\nimport type { SetupVisOptions } from 'vitest-plugin-vis'\nimport { autoSnapshotMatcher, setAutoSnapshotOptions, toSuiteDefaults } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './client/expect/to_match_image_snapshot.ts'\nimport { isVitestBrowser } from './client/is_vitest_browser.ts'\nimport { cdp, commands, page, whenVitestProxyReady } from './client/vitest_proxy.ts'\nimport { visAnnotations } from './preview/vis_annotation.ts'\n\n// Register at module load time so it's available in Storybook dev mode.\n// (visAnnotations.beforeEach is only wired via vitest's setProjectAnnotations, not in dev mode)\nexpect.extend({ toMatchImageSnapshot })\n\nexport * from 'vitest-plugin-vis'\nexport * from './client/has_image_snapshot.ts'\nexport * from './client/storybook/param.ts'\nexport * from './client/storybook/tags.ts'\n\nexport { cdp, page, visAnnotations }\n\nexport default (options: SetupVisOptions<{ tags: string[] }> = { auto: false }) => {\n\tlet matcher: ReturnType<typeof autoSnapshotMatcher>\n\tlet matcherFn: () => Promise<void>\n\treturn definePreviewAddon({\n\t\ttags: options.auto === true ? ['snapshot'] : [],\n\t\tasync beforeAll() {\n\t\t\tif (!isVitestBrowser()) return\n\t\t\t// `page` and `getCurrentTest` come from a dynamic import; the hooks that\n\t\t\t// follow read them synchronously, so wait for it here (#835).\n\t\t\tawait whenVitestProxyReady()\n\t\t\tmatcher = autoSnapshotMatcher(commands, expect)\n\t\t\tconst suiteDefaults = toSuiteDefaults(options)\n\t\t\tif (typeof options?.auto === 'function') {\n\t\t\t\tmatcherFn = matcher.createMatcher(\n\t\t\t\t\t{\n\t\t\t\t\t\tauto: options.auto,\n\t\t\t\t\t},\n\t\t\t\t\tsuiteDefaults,\n\t\t\t\t)\n\t\t\t} else if (typeof options?.auto === 'object') {\n\t\t\t\tmatcherFn = matcher.createMatcher(options.auto, suiteDefaults)\n\t\t\t} else matcherFn = matcher.createMatcher({ async auto() {} }, suiteDefaults)\n\n\t\t\tawait matcher.setup()\n\t\t\tawait setAutoSnapshotOptions(true)\n\t\t},\n\t\tafterEach() {\n\t\t\tif (matcherFn) {\n\t\t\t\treturn matcherFn()\n\t\t\t}\n\t\t},\n\t\t...visAnnotations,\n\t})\n}\n"],"mappings":";;;;;;;;AAEA,MAAa,MAAM;CAClB;CACA,gBAAgB;AACf,MAAI,iBAAiB;;CAEtB;;;;;;;ACAD,SAAgB,iBAAiB,SAA+C;CAC/E,MAAM,OAAO,IAAI,gBAAgB;AACjC,KAAI,CAAC,KAAM,QAAO;AAElB,QAAO,uBAAuB,UAAU,SAAS,KAAK,EAAE,QAAQ;;;;;;;;ACiBjE,SAAgB,wBACf,UACC;AACD,QAAO,EAAE,UAAU;;;;;ACjBpB,OAAO,OAAO,EAAE,sBAAsB,CAAC;AASvC,mBAAgB,UAA+C,EAAE,MAAM,OAAO,KAAK;CAClF,IAAI;CACJ,IAAI;AACJ,QAAO,mBAAmB;EACzB,MAAM,QAAQ,SAAS,OAAO,CAAC,WAAW,GAAG,EAAE;EAC/C,MAAM,YAAY;AACjB,OAAI,CAAC,iBAAiB,CAAE;AAGxB,SAAM,sBAAsB;AAC5B,aAAU,oBAAoB,UAAU,OAAO;GAC/C,MAAM,gBAAgB,gBAAgB,QAAQ;AAC9C,OAAI,OAAO,SAAS,SAAS,WAC5B,aAAY,QAAQ,cACnB,EACC,MAAM,QAAQ,MACd,EACD,cACA;YACS,OAAO,SAAS,SAAS,SACnC,aAAY,QAAQ,cAAc,QAAQ,MAAM,cAAc;OACxD,aAAY,QAAQ,cAAc,EAAE,MAAM,OAAO,IAAI,EAAE,cAAc;AAE5E,SAAM,QAAQ,OAAO;AACrB,SAAM,uBAAuB,KAAK;;EAEnC,YAAY;AACX,OAAI,UACH,QAAO,WAAW;;EAGpB,GAAG;EACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as storybook_internal_types0 from "storybook/internal/types";
|
|
2
|
+
|
|
3
|
+
//#region src/preview/vis_annotation.d.ts
|
|
4
|
+
declare const visAnnotations: {
|
|
5
|
+
beforeEach(ctx: storybook_internal_types0.StoryContext<any, storybook_internal_types0.Args>): void;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { visAnnotations as t };
|
|
9
|
+
//# sourceMappingURL=vis_annotation-pQo0FcfJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vis_annotation-pQo0FcfJ.d.mts","names":[],"sources":["../src/preview/vis_annotation.ts"],"sourcesContent":[],"mappings":";;;cAUa;kBAgBoC,yBAAA,CAAA,kBAAA,yBAAA,CAAA,IAAA"}
|
package/llms.txt
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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/visual-testing/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/visual-testing/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,26 +20,48 @@ Import from the entry points listed below, not from package internals. Documenta
|
|
|
20
20
|
|
|
21
21
|
## Documentation
|
|
22
22
|
|
|
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:
|
|
25
|
-
- [storybook-addon-vis:
|
|
23
|
+
- [storybook-addon-vis: Automatic snapshots](https://repobuddy.github.io/visual-testing/addon/guides/automatic-snapshots/): Take an image snapshot of every story without writing test code.
|
|
24
|
+
- [storybook-addon-vis: CI](https://repobuddy.github.io/visual-testing/addon/guides/ci/): Run story snapshots on CI with platform baselines.
|
|
25
|
+
- [storybook-addon-vis: CSF Next and story.test()](https://repobuddy.github.io/visual-testing/addon/guides/csf-next/): Set up visual testing in the preview for CSF Next stories.
|
|
26
|
+
- [storybook-addon-vis: Chrome DevTools Protocol](https://repobuddy.github.io/visual-testing/addon/guides/chrome-devtools-protocol/): Use cdp() inside a story under Playwright and Chromium.
|
|
27
|
+
- [storybook-addon-vis: Features](https://repobuddy.github.io/visual-testing/addon/features/): Every capability of the addon, each linked to its guide.
|
|
28
|
+
- [storybook-addon-vis: Install](https://repobuddy.github.io/visual-testing/addon/get-started/): Install storybook-addon-vis and its peer dependencies.
|
|
29
|
+
- [storybook-addon-vis: Manual snapshots](https://repobuddy.github.io/visual-testing/addon/guides/manual-snapshots/): Take snapshots in a play function, check that one exists, and use the Chrome DevTools Protocol.
|
|
30
|
+
- [storybook-addon-vis: Monorepos and custom snapshot paths](https://repobuddy.github.io/visual-testing/addon/guides/monorepo-and-paths/): Tell the Vis panel where the snapshots are.
|
|
26
31
|
- [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
32
|
- [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:
|
|
33
|
+
- [storybook-addon-vis: Reviewing failures (addon view)](https://repobuddy.github.io/visual-testing/addon/guides/reviewing-failures/): Find what changed when a story snapshot fails.
|
|
34
|
+
- [storybook-addon-vis: Setup](https://repobuddy.github.io/visual-testing/addon/configuration/): Configure Storybook, Vitest, TypeScript and .gitignore for storybook-addon-vis. Documents: cdp, default, defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, page, visAnnotations, experimental_serverChannel, storybookVis, vis.
|
|
35
|
+
- [storybook-addon-vis: The Vis panel](https://repobuddy.github.io/visual-testing/addon/guides/the-vis-panel/): Review baseline, result and diff of a story inside Storybook.
|
|
36
|
+
- [storybook-addon-vis: Themes](https://repobuddy.github.io/visual-testing/addon/guides/themes/): Take every snapshot once per theme, such as light and dark.
|
|
37
|
+
- [storybook-addon-vis: Thresholds and comparison for stories](https://repobuddy.github.io/visual-testing/addon/guides/thresholds-and-comparison/): Tolerate small differences and pick pixel or SSIM comparison for stories.
|
|
29
38
|
- [storybook-addon-vis: Troubleshooting](https://repobuddy.github.io/visual-testing/addon/troubleshooting/): Fix common installation and runtime problems.
|
|
30
|
-
- [storybook-addon-vis:
|
|
31
|
-
- [storybook-addon-vis: node
|
|
32
|
-
- [storybook-addon-vis: node/
|
|
33
|
-
- [
|
|
34
|
-
- [vitest-plugin-vis:
|
|
39
|
+
- [storybook-addon-vis: Viewports and multiple instances](https://repobuddy.github.io/visual-testing/addon/guides/viewports-and-multiple-instances/): Snapshot the same stories at several browser sizes.
|
|
40
|
+
- [storybook-addon-vis: node](https://repobuddy.github.io/visual-testing/addon/reference/node/): `storybook-addon-vis/node` provides functionality to configure the Storybook Visual Testing addon in the `.storybook/main.ts` file.
|
|
41
|
+
- [storybook-addon-vis: node/defineStorybookVis](https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis/): A helper function to configure the Storybook Visual Testing addon in `.storybook/main.ts`. Documents: defineStorybookVis.
|
|
42
|
+
- [storybook-addon-vis: node/defineStorybookVisOptions](https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis-options/): A helper function to configure options for Storybook Visual Testing addon. Documents: defineStorybookVisOptions.
|
|
43
|
+
- [vitest-plugin-vis: auto snapshots/setAutoSnapshotOptions](https://repobuddy.github.io/visual-testing/plugin/reference/set-auto-snapshot-options/): A function to configure visual snapshot testing options for the current test or test suite. Documents: setAutoSnapshotOptions.
|
|
44
|
+
- [vitest-plugin-vis: client-api](https://repobuddy.github.io/visual-testing/plugin/reference/client-api/): The browser-side building blocks of vitest-plugin-vis, for tools that build on the plugin. Documents: AnimationsOptions, Awaitable, ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MaskLocator, MaskOptions, MatchImageSnapshotOptions, MetaTask, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, ReviewImageOptions, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions.
|
|
45
|
+
- [vitest-plugin-vis: config/trimCommonFolder](https://repobuddy.github.io/visual-testing/plugin/reference/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.
|
|
46
|
+
|
|
47
|
+
## Visual testing concepts
|
|
48
|
+
|
|
49
|
+
- [What is visual testing](https://repobuddy.github.io/visual-testing/visual-testing/what-is-visual-testing/): What visual testing catches and misses, and the loop of writing, snapshotting, comparing, reviewing and updating.
|
|
50
|
+
- [How snapshots work](https://repobuddy.github.io/visual-testing/visual-testing/how-snapshots-work/): Baseline, result and diff images, the __vis__ folder layout, and what to commit and what to ignore.
|
|
51
|
+
- [Comparison and thresholds](https://repobuddy.github.io/visual-testing/visual-testing/comparison-and-thresholds/): How a result is compared with its baseline: pixel and SSIM methods, failure thresholds in pixels or percent, and how to choose.
|
|
52
|
+
- [Platforms and CI](https://repobuddy.github.io/visual-testing/visual-testing/platforms-and-ci/): Why baselines are kept per platform, how local runs differ from CI, and how to keep baselines current in CI.
|
|
53
|
+
- [Updating baselines](https://repobuddy.github.io/visual-testing/visual-testing/updating-baselines/): Create the first baselines and update them after an intended change, with createMissingBaseline, updateSnapshot and vitest -u.
|
|
54
|
+
- [Reviewing failures](https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures/): Read a failed image snapshot: the error message, the diff, the review image, the regions file, the Vis panel and git diff.
|
|
55
|
+
- [Variations](https://repobuddy.github.io/visual-testing/visual-testing/variations/): Take the same test in several themes, viewports and browsers, and when each one pays off.
|
|
56
|
+
- [Choosing a package](https://repobuddy.github.io/visual-testing/visual-testing/choosing-a-package/): Pick storybook-addon-vis for Storybook stories or vitest-plugin-vis for Vitest Browser Mode tests, and see how they relate.
|
|
35
57
|
|
|
36
58
|
## Entry points
|
|
37
59
|
|
|
38
|
-
- [`storybook-addon-vis`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/index.ts): default export; functions: defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, setAutoSnapshotOptions; types: Awaitable, ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MatchImageSnapshotOptions, MetaTask, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, ReviewImageOptions, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions; values: cdp, page, visAnnotations (
|
|
60
|
+
- [`storybook-addon-vis`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/index.ts): default export; functions: defineAutoSnapshotParam, hasImageSnapshot, isSnapshotEnabled, setAutoSnapshotOptions; types: AnimationsOptions, Awaitable, ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MaskLocator, MaskOptions, MatchImageSnapshotOptions, MetaTask, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, ReviewImageOptions, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions; values: cdp, page, visAnnotations (31 exports, 31 with a documentation page).
|
|
39
61
|
- [`storybook-addon-vis/manager`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/manager.tsx): no named exports; it is imported for its side effects.
|
|
40
62
|
- [`storybook-addon-vis/matcher`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/matcher.ts): no named exports; it is imported for its side effects.
|
|
41
63
|
- [`storybook-addon-vis/node`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/node.ts): functions: defineStorybookVis, defineStorybookVisOptions (2 exports, 2 with a documentation page).
|
|
42
|
-
- [`storybook-addon-vis/preset`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/preset.ts): value: experimental_serverChannel (1 export,
|
|
64
|
+
- [`storybook-addon-vis/preset`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/preset.ts): value: experimental_serverChannel (1 export, 1 with a documentation page).
|
|
43
65
|
- [`storybook-addon-vis/vitest-plugin`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/vitest-plugin.ts): functions: storybookVis, trimCommonFolder (2 exports, 2 with a documentation page).
|
|
44
66
|
- [`storybook-addon-vis/vitest-setup`](https://github.com/repobuddy/visual-testing/blob/main/packages/storybook-addon-vis/src/exports/vitest-setup.ts): function: setAutoSnapshotOptions; values: vis, visAnnotations (3 exports, 3 with a documentation page).
|
|
45
67
|
|
|
@@ -48,4 +70,4 @@ Import from the entry points listed below, not from package internals. Documenta
|
|
|
48
70
|
- [storybook-addon-vis: Changelog](https://repobuddy.github.io/visual-testing/releases/changelog-addon/): Release history of storybook-addon-vis.
|
|
49
71
|
- [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.
|
|
50
72
|
|
|
51
|
-
Documentation coverage:
|
|
73
|
+
Documentation coverage: 37 of 37 distinct exported declarations are named on a documentation page; 7 carry a doc comment.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Storybook Vitest visual testing addon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"image-snapshot",
|
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@just-web/react-image-compare": "^0.1.1",
|
|
67
67
|
"@storybook/icons": "^2.1.0",
|
|
68
|
-
"glob": "^
|
|
68
|
+
"glob": "^14.0.2",
|
|
69
69
|
"is-ci": "^4.1.0",
|
|
70
70
|
"memoize": "^11.0.0",
|
|
71
71
|
"pathe": "^2.0.3",
|
|
72
72
|
"type-plus": "8.0.1",
|
|
73
|
-
"vitest-plugin-vis": "^5.
|
|
73
|
+
"vitest-plugin-vis": "^5.4.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@repobuddy/storybook": "^2.33.4",
|
package/readme.md
CHANGED
|
@@ -151,16 +151,16 @@ The site-wide copy is at <https://repobuddy.github.io/visual-testing/llms.txt>.
|
|
|
151
151
|
|
|
152
152
|
[@storybook/experimental-addon-test]: https://www.npmjs.com/package/@storybook/experimental-addon-test
|
|
153
153
|
[docs]: https://repobuddy.github.io/visual-testing/
|
|
154
|
-
[docs_agents]: https://repobuddy.github.io/visual-testing/
|
|
155
|
-
[docs_auto]: https://repobuddy.github.io/visual-testing/addon/automatic-snapshots/
|
|
156
|
-
[docs_define]: https://repobuddy.github.io/visual-testing/reference/
|
|
157
|
-
[docs_define_options]: https://repobuddy.github.io/visual-testing/reference/
|
|
158
|
-
[docs_install]: https://repobuddy.github.io/visual-testing/addon/
|
|
159
|
-
[docs_manual]: https://repobuddy.github.io/visual-testing/addon/manual-snapshots/
|
|
154
|
+
[docs_agents]: https://repobuddy.github.io/visual-testing/visual-testing/reviewing-failures-with-agents/
|
|
155
|
+
[docs_auto]: https://repobuddy.github.io/visual-testing/addon/guides/automatic-snapshots/
|
|
156
|
+
[docs_define]: https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis/
|
|
157
|
+
[docs_define_options]: https://repobuddy.github.io/visual-testing/addon/reference/define-storybook-vis-options/
|
|
158
|
+
[docs_install]: https://repobuddy.github.io/visual-testing/addon/get-started/
|
|
159
|
+
[docs_manual]: https://repobuddy.github.io/visual-testing/addon/guides/manual-snapshots/
|
|
160
160
|
[docs_migrate_1]: https://repobuddy.github.io/visual-testing/releases/migrate-to-1/
|
|
161
161
|
[docs_migrate_3]: https://repobuddy.github.io/visual-testing/releases/migrate-to-3/
|
|
162
|
-
[docs_setup]: https://repobuddy.github.io/visual-testing/addon/
|
|
163
|
-
[docs_setup_10_3]: https://repobuddy.github.io/visual-testing/addon/
|
|
162
|
+
[docs_setup]: https://repobuddy.github.io/visual-testing/addon/configuration/
|
|
163
|
+
[docs_setup_10_3]: https://repobuddy.github.io/visual-testing/addon/configuration/#storybook-103-and-vitest-project-annotations
|
|
164
164
|
[docs_troubleshooting]: https://repobuddy.github.io/visual-testing/addon/troubleshooting/
|
|
165
165
|
[downloads_image]: https://img.shields.io/npm/dm/storybook-addon-vis.svg?style=flat
|
|
166
166
|
[github_action_url]: https://github.com/repobuddy/visual-testing/actions/workflows/release.yml
|
|
@@ -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 [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/
|
|
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/visual-testing/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 [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/
|
|
30
|
+
Full explanation and measured token costs: the [Reviewing Failures with Agents](https://repobuddy.github.io/visual-testing/visual-testing/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
|
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import './shared/global_matcher_augment.ts'
|
|
|
4
4
|
import { definePreviewAddon } from 'storybook/internal/csf'
|
|
5
5
|
import { expect } from 'storybook/test'
|
|
6
6
|
import type { SetupVisOptions } from 'vitest-plugin-vis'
|
|
7
|
-
import { autoSnapshotMatcher, setAutoSnapshotOptions } from 'vitest-plugin-vis/client-api'
|
|
7
|
+
import { autoSnapshotMatcher, setAutoSnapshotOptions, toSuiteDefaults } from 'vitest-plugin-vis/client-api'
|
|
8
8
|
import { toMatchImageSnapshot } from './client/expect/to_match_image_snapshot.ts'
|
|
9
9
|
import { isVitestBrowser } from './client/is_vitest_browser.ts'
|
|
10
10
|
import { cdp, commands, page, whenVitestProxyReady } from './client/vitest_proxy.ts'
|
|
@@ -32,10 +32,7 @@ export default (options: SetupVisOptions<{ tags: string[] }> = { auto: false })
|
|
|
32
32
|
// follow read them synchronously, so wait for it here (#835).
|
|
33
33
|
await whenVitestProxyReady()
|
|
34
34
|
matcher = autoSnapshotMatcher(commands, expect)
|
|
35
|
-
const suiteDefaults =
|
|
36
|
-
options?.createMissingBaseline !== undefined
|
|
37
|
-
? { createMissingBaseline: options.createMissingBaseline }
|
|
38
|
-
: undefined
|
|
35
|
+
const suiteDefaults = toSuiteDefaults(options)
|
|
39
36
|
if (typeof options?.auto === 'function') {
|
|
40
37
|
matcherFn = matcher.createMatcher(
|
|
41
38
|
{
|
package/src/overview.mdx
CHANGED
|
@@ -571,6 +571,20 @@ This is useful when you are performing some negative test.
|
|
|
571
571
|
|
|
572
572
|
|
|
573
573
|
|
|
574
|
+
## Usage - CSF Next preview addon
|
|
575
|
+
|
|
576
|
+
The default export of `storybook-addon-vis`, `addonVis()`, is the preview addon for CSF Next.
|
|
577
|
+
Pass it to `definePreview({ addons: [addonVis({ auto: true })] })`.
|
|
578
|
+
|
|
579
|
+
## Usage - tag helper
|
|
580
|
+
|
|
581
|
+
`isSnapshotEnabled(tags)` applies the tag rule: the last of `snapshot` and `!snapshot` wins, and no tag means no snapshot.
|
|
582
|
+
|
|
583
|
+
## Usage - Vis panel server hook
|
|
584
|
+
|
|
585
|
+
`storybook-addon-vis/preset` exports `experimental_serverChannel`, which Storybook calls so that the Vis panel can read the snapshot images.
|
|
586
|
+
You do not call it yourself.
|
|
587
|
+
|
|
574
588
|
## Usage - Chrome DevTools Protocol
|
|
575
589
|
|
|
576
590
|
`cdp` is a proxy of `cdp()` from `vitest/browser`.
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as storybook_internal_csf1 from "storybook/internal/csf";
|
|
2
|
-
|
|
3
|
-
//#region src/preview/vis_annotation.d.ts
|
|
4
|
-
declare const visAnnotations: {
|
|
5
|
-
beforeEach(ctx: storybook_internal_csf1.StoryContext<any, storybook_internal_csf1.Args>): void;
|
|
6
|
-
};
|
|
7
|
-
//#endregion
|
|
8
|
-
export { visAnnotations as t };
|
|
9
|
-
//# sourceMappingURL=vis_annotation-N0xbuXis.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vis_annotation-N0xbuXis.d.mts","names":[],"sources":["../src/preview/vis_annotation.ts"],"sourcesContent":[],"mappings":";;;cAUa;kBAgBoC,uBAAA,CAAA,kBAAA,uBAAA,CAAA,IAAA"}
|