storybook-addon-vis 4.7.0 → 4.8.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "storybook-addon-vis",
3
3
  "version": "4.3.2",
4
- "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
4
+ "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
5
5
  "author": {
6
6
  "name": "Homa Wong",
7
7
  "email": "homawong@gmail.com",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "storybook-addon-vis",
3
3
  "version": "4.3.2",
4
- "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
4
+ "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
5
5
  "author": {
6
6
  "name": "Homa Wong",
7
7
  "email": "homawong@gmail.com",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "storybook-addon-vis",
3
3
  "version": "4.3.2",
4
- "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
4
+ "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
5
5
  "author": {
6
6
  "name": "Homa Wong",
7
7
  "email": "homawong@gmail.com",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # CHANGE LOG
2
2
 
3
+ ## 4.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1037](https://github.com/repobuddy/visual-testing/pull/1037) [`ec0f3c4`](https://github.com/repobuddy/visual-testing/commit/ec0f3c45ee1c830b936ea7b0f506c1a9b37eaa25) Thanks [@unional](https://github.com/unional)! - Add the `storybook-addon-vis prune [--dry-run]` command. It runs the `vitest-plugin-vis prune` command of the `vitest-plugin-vis` the addon depends on, so addon users can run it with their package manager without `npx` or `pnpm dlx` fetching a different version.
8
+
9
+ - [#1033](https://github.com/repobuddy/visual-testing/pull/1033) [`8660a45`](https://github.com/repobuddy/visual-testing/commit/8660a45a9da43df6bfdfe13e7894eb63026437da) Thanks [@unional](https://github.com/unional)! - Ship the `remove-obsolete-image-snapshots` agent skill. It tells a coding agent to run the full suite, read the obsolete image snapshot list, keep the baselines of tests that run only on some platforms or runs, and remove the rest with `-u` or `vitest-plugin-vis prune`.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [[`ec0f3c4`](https://github.com/repobuddy/visual-testing/commit/ec0f3c45ee1c830b936ea7b0f506c1a9b37eaa25), [`8660a45`](https://github.com/repobuddy/visual-testing/commit/8660a45a9da43df6bfdfe13e7894eb63026437da), [`b423380`](https://github.com/repobuddy/visual-testing/commit/b4233806626f3aceef39659365627cc7b001125b)]:
14
+ - vitest-plugin-vis@5.7.0
15
+
3
16
  ## 4.7.0
4
17
 
5
18
  ### Minor Changes
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import { runCli } from "vitest-plugin-vis/cli";
3
+
4
+ // src/bin/storybook-addon-vis.ts
5
+ process.exitCode = await runCli(process.argv.slice(2), {
6
+ cwd: process.cwd(),
7
+ name: "storybook-addon-vis",
8
+ log: (m) => process.stdout.write(`${m}\n`),
9
+ error: (m) => process.stderr.write(`${m}\n`)
10
+ });
11
+
12
+ export { };
13
+ //# sourceMappingURL=storybook-addon-vis.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook-addon-vis.mjs","names":[],"sources":["../../src/bin/storybook-addon-vis.ts"],"sourcesContent":["#!/usr/bin/env node\n// Resolves `vitest-plugin-vis` from this package's own dependency,\n// so the command always matches the plugin version the addon runs with.\nimport { runCli } from 'vitest-plugin-vis/cli'\n\nprocess.exitCode = await runCli(process.argv.slice(2), {\n\tcwd: process.cwd(),\n\tname: 'storybook-addon-vis',\n\tlog: (m) => process.stdout.write(`${m}\\n`),\n\terror: (m) => process.stderr.write(`${m}\\n`),\n})\n"],"mappings":";;;;AAKA,QAAQ,WAAW,MAAM,OAAO,QAAQ,KAAK,MAAM,CAAC,GAAG;CACtD,KAAK,QAAQ,IAAI;CACjB,MAAM;CACN,MAAM,MAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,GAAG;CACzC,QAAQ,MAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,GAAG;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-vis",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Storybook Vitest visual testing addon",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -48,6 +48,9 @@
48
48
  "./package.json": "./package.json"
49
49
  },
50
50
  "types": "./dist/index.d.mts",
51
+ "bin": {
52
+ "storybook-addon-vis": "./dist/bin/storybook-addon-vis.mjs"
53
+ },
51
54
  "files": [
52
55
  "dist",
53
56
  "src",
@@ -70,7 +73,7 @@
70
73
  "memoize": "^11.0.0",
71
74
  "pathe": "^2.0.3",
72
75
  "type-plus": "8.0.1",
73
- "vitest-plugin-vis": "^5.6.0"
76
+ "vitest-plugin-vis": "^5.7.0"
74
77
  },
75
78
  "devDependencies": {
76
79
  "@repobuddy/storybook": "^2.33.4",
package/plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "storybook-addon-vis",
4
4
  "version": "4.3.2",
5
- "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image.",
5
+ "description": "Review failed image snapshots from storybook-addon-vis cheaply: read the message, then the review image. Remove obsolete baselines without losing the ones a gated test still needs.",
6
6
  "author": {
7
7
  "name": "Homa Wong",
8
8
  "email": "homawong@gmail.com",
@@ -0,0 +1,18 @@
1
+ # remove-obsolete-image-snapshots
2
+
3
+ Removes obsolete image snapshot baselines without deleting the ones a skipped or platform-gated test still needs.
4
+
5
+ ## When to use
6
+
7
+ An agent loads it when a run prints `obsolete image snapshots found`, or when it is asked to clean up old or orphaned image snapshots. It is not a slash command (`user-invocable: false`).
8
+
9
+ ## What it does
10
+
11
+ 1. Runs the full suite with no filter, so the folders of deleted or moved test files are listed too.
12
+ 2. Reads the obsolete list at the end of the run.
13
+ 3. Checks each entry for tests that exist or take snapshots only on some platforms or runs, and keeps their baselines.
14
+ 4. Removes the rest with `-u`, or with `vitest-plugin-vis prune [--dry-run]` (`storybook-addon-vis prune [--dry-run]` in the addon) for folders of deleted or moved test files on other platforms. When `prune` refuses, it relies on the full run's list.
15
+
16
+ ## Install
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 behavior it relies on is on the [Updating baselines](https://repobuddy.github.io/visual-testing/visual-testing/updating-baselines/#obsolete-baselines) page.
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: remove-obsolete-image-snapshots
3
+ user-invocable: false
4
+ description: Removes obsolete image snapshot baselines from vitest-plugin-vis without deleting ones a skipped or platform-gated test still needs. Use this skill when a test run prints `obsolete image snapshots found`, or when asked to clean up, prune, or remove old, unused, or orphaned image snapshots or baselines.
5
+ ---
6
+
7
+ # Remove obsolete image snapshots
8
+
9
+ At the end of a run, `vitest-plugin-vis` lists the baselines the run did not use:
10
+
11
+ ```txt
12
+ vis 2 obsolete image snapshots found. Run with -u to remove them.
13
+ ↳ __vis__/local/__baselines__/button.spec.tsx/old-name-1.png
14
+ ```
15
+
16
+ With `-u` it deletes them. It already keeps the baselines of skipped, todo, and failed tests. This skill covers what it cannot see.
17
+
18
+ ## Steps
19
+
20
+ 1. **Run the full suite.** Use the project's own test command, with no `--project`, file, `-t`, `--shard`, or `--changed` filter. A filtered run does not list the folders of deleted or moved test files. Do not pass `-u` yet.
21
+ 2. **Read the obsolete list** at the end of the output. If the run was interrupted or had an unhandled error, nothing is listed: fix that first.
22
+ 3. **Check each listed file before deleting it.** Open the test file of its folder (`__baselines__/<test file>/`) and find the test or story the file name starts with. Keep the baseline, and do not run `-u`, if:
23
+ - the test exists only on some platforms, browsers, or environments: defined inside an `if`, or gated by `skipIf` or `runIf` on a condition that differs between machines;
24
+ - the snapshot is taken only on some runs: `toMatchImageSnapshot` inside an `if`, a loop over data that changes, or a test that reads an environment variable;
25
+ - the story is included by tags or a filter that differs between runs (Storybook).
26
+
27
+ A file whose test is gone, or that takes fewer snapshots than before, is obsolete.
28
+ 4. **Remove the obsolete files.**
29
+ - If every listed file is obsolete, run the same full command with `-u`. It deletes them and the folders they leave empty, and updates failing snapshots too, so the run must have no failing snapshot you have not reviewed.
30
+ - If some must be kept, do not run `-u`. Delete the obsolete files one by one instead, and report the kept ones and why.
31
+ - For the folders of deleted or moved test files on other platforms (for example `__vis__/linux/` and `__vis__/win32/` when you run locally), or when the full run used `--project`, the run cannot see them. From the folder of the package whose baselines you clean (in a monorepo, one package at a time, because it scans every config under the current folder and refuses for all of them if one sets `snapshotSubpath`), run `vitest-plugin-vis prune --dry-run` through the project's package manager (`pnpm exec`, `npx`, `yarn`, or `bunx`). With `storybook-addon-vis`, run `storybook-addon-vis prune --dry-run` instead: it runs the `vitest-plugin-vis` the addon depends on, so the version matches. Do not use `npx vitest-plugin-vis` or `pnpm dlx vitest-plugin-vis` there, because they can fetch a different version from the registry. Check each listed folder the same way: a test file that exists only on some branches or is generated keeps its folder. Then run the same command without `--dry-run` to delete them.
32
+ - If `prune` refuses (exit code 1), because a config sets `snapshotSubpath` or no folder matches a test file, it deleted nothing. Do not delete its folders by hand. Rely on the full run's list and report that `prune` could not map the folders. A warning about `shortenLongSnapshotPaths` is not a refusal: it keeps the folders with shortened names, which you leave in place.
33
+
34
+ ## Validate
35
+
36
+ - The full suite ran with no filter before anything was deleted.
37
+ - Every deleted baseline was checked against its test file.
38
+ - No baseline of a platform-gated or conditional test was deleted.
39
+ - `git status` shows only deletions under `__baselines__`, and the report names each kept baseline and why.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ // Resolves `vitest-plugin-vis` from this package's own dependency,
3
+ // so the command always matches the plugin version the addon runs with.
4
+ import { runCli } from 'vitest-plugin-vis/cli'
5
+
6
+ process.exitCode = await runCli(process.argv.slice(2), {
7
+ cwd: process.cwd(),
8
+ name: 'storybook-addon-vis',
9
+ log: (m) => process.stdout.write(`${m}\n`),
10
+ error: (m) => process.stderr.write(`${m}\n`),
11
+ })