storybook-addon-vis 4.2.0 → 4.2.2

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,4 +1,4 @@
1
- import { r as commands, t as visAnnotations } from "../vis_annotation-CTT7sNWa.mjs";
1
+ import { r as commands, t as visAnnotations } from "../vis_annotation-Bst4UkfF.mjs";
2
2
  import { setAutoSnapshotOptions } from "vitest-plugin-vis";
3
3
  import { createVis } from "vitest-plugin-vis/setup-api";
4
4
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as page, i as getCurrentTest, n as isSnapshotEnabled, r as commands, t as visAnnotations } from "./vis_annotation-CTT7sNWa.mjs";
1
+ import { a as page, i as getCurrentTest, n as isSnapshotEnabled, r as commands, t as visAnnotations } from "./vis_annotation-Bst4UkfF.mjs";
2
2
  import { definePreviewAddon } from "storybook/internal/csf";
3
3
  import { expect } from "storybook/test";
4
4
  import { autoSnapshotMatcher, hasImageSnapshotAction, setAutoSnapshotOptions, toTaskId } from "vitest-plugin-vis/client-api";
@@ -1,5 +1,6 @@
1
1
  import { expect } from "storybook/test";
2
2
  import { matchImageSnapshotAction, matchPageImageSnapshotAction, success, toTaskId } from "vitest-plugin-vis/client-api";
3
+ import { isRunningInTest } from "@repobuddy/test";
3
4
  import { setAutoSnapshotOptions as setAutoSnapshotOptions$1 } from "vitest-plugin-vis";
4
5
 
5
6
  //#region src/client/page/to_match_image_snapshot.ts
@@ -57,6 +58,7 @@ function isSnapshotEnabled(tags) {
57
58
  //#region src/preview/vis_annotation.ts
58
59
  let extended = false;
59
60
  const visAnnotations = { beforeEach(ctx) {
61
+ if (!isRunningInTest()) return;
60
62
  if (!extended) {
61
63
  expect.extend({ toMatchImageSnapshot });
62
64
  extended = true;
@@ -72,4 +74,4 @@ const visAnnotations = { beforeEach(ctx) {
72
74
 
73
75
  //#endregion
74
76
  export { page as a, getCurrentTest as i, isSnapshotEnabled as n, commands as r, visAnnotations as t };
75
- //# sourceMappingURL=vis_annotation-CTT7sNWa.mjs.map
77
+ //# sourceMappingURL=vis_annotation-Bst4UkfF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"vis_annotation-CTT7sNWa.mjs","names":["toMatchImageSnapshot"],"sources":["../src/client/page/to_match_image_snapshot.ts","../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/tags.ts","../src/preview/vis_annotation.ts"],"sourcesContent":["import {\n\ttype ComparisonMethod,\n\ttype ToMatchPageImageSnapshotOptions,\n\tmatchPageImageSnapshotAction,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n) {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve()\n\t/* v8 ignore end */\n\n\treturn matchPageImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'\nimport type { BrowserCommands, BrowserPage } from 'vitest/browser'\nimport { toMatchImageSnapshot } from './page/to_match_image_snapshot.ts'\n\nlet browserContext: Awaited<typeof import('vitest/browser')>\nlet vitest: Awaited<typeof import('vitest')>\n\nif ((globalThis as any).__vitest_browser__) {\n\timport('vitest/browser').then((m) => {\n\t\tm.page.extend({ toMatchImageSnapshot })\n\t\tbrowserContext = m\n\t})\n\timport('vitest').then((m) => {\n\t\tvitest = m\n\t})\n}\n\nexport const page = new Proxy<BrowserPage>({} as any, {\n\tget(_target, prop) {\n\t\tconst r = (browserContext?.page as any)?.[prop]\n\t\tif (prop === 'toMatchImageSnapshot' && r === undefined) {\n\t\t\treturn () => {}\n\t\t}\n\t\treturn r\n\t},\n})\n\nexport const commands = new Proxy<BrowserCommands>({} as any, {\n\tget(_target, prop) {\n\t\treturn (browserContext?.commands as any)?.[prop]\n\t},\n})\n\nexport const getCurrentTest = () =>\n\tvitest?.TestRunner.getCurrentTest() as\n\t\t| (ReturnType<typeof vitest.TestRunner.getCurrentTest> & SnapshotTestMeta)\n\t\t| undefined\n","import type { AsyncExpectationResult } from '@vitest/expect'\nimport {\n\ttype ComparisonMethod,\n\ttype ToMatchImageSnapshotOptions,\n\tmatchImageSnapshotAction,\n\tsuccess,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod>(\n\t/**\n\t * The element or locator to take the snapshot of,\n\t * or the base64 value of the image to compare against.\n\t */\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions<M> | undefined,\n): AsyncExpectationResult {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve(success)\n\t/* v8 ignore end */\n\n\treturn matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success)\n}\n","export function isSnapshotEnabled(tags: string[]) {\n\tconst noSnapshotIndex = tags.lastIndexOf('!snapshot')\n\tconst snapshotIndex = tags.lastIndexOf('snapshot')\n\n\tif (noSnapshotIndex < 0 && snapshotIndex < 0) return false\n\n\treturn noSnapshotIndex < snapshotIndex\n}\n","import type { NamedOrDefaultProjectAnnotations } from 'storybook/internal/types'\nimport { expect } from 'storybook/test'\nimport { setAutoSnapshotOptions } from 'vitest-plugin-vis'\nimport { toMatchImageSnapshot } from '../client/expect/to_match_image_snapshot.ts'\nimport { isSnapshotEnabled } from '../client/storybook/tags.ts'\nimport { getCurrentTest } from '../client/vitest_proxy.ts'\n\nlet extended = false\n\nexport const visAnnotations = {\n\tbeforeEach(ctx) {\n\t\tif (!extended) {\n\t\t\texpect.extend({ toMatchImageSnapshot })\n\t\t\textended = true\n\t\t}\n\t\tconst test = getCurrentTest()\n\n\t\tsetAutoSnapshotOptions({\n\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,IAAI,WAAW;AAEf,MAAa,iBAAiB,EAC7B,WAAW,KAAK;AACf,KAAI,CAAC,UAAU;AACd,SAAO,OAAO,EAAE,sBAAsB,CAAC;AACvC,aAAW;;CAEZ,MAAM,OAAO,gBAAgB;AAE7B,0BAAuB;EACtB,QAAQ,kBAAkB,IAAI,KAAK;EACnC,GAAG,IAAI,YAAY;EACnB,MAAM,IAAI;EACV,GAAG,MAAM,KAAK;EACd,CAAC;GAEH"}
1
+ {"version":3,"file":"vis_annotation-Bst4UkfF.mjs","names":["toMatchImageSnapshot"],"sources":["../src/client/page/to_match_image_snapshot.ts","../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/tags.ts","../src/preview/vis_annotation.ts"],"sourcesContent":["import {\n\ttype ComparisonMethod,\n\ttype ToMatchPageImageSnapshotOptions,\n\tmatchPageImageSnapshotAction,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n) {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve()\n\t/* v8 ignore end */\n\n\treturn matchPageImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'\nimport type { BrowserCommands, BrowserPage } from 'vitest/browser'\nimport { toMatchImageSnapshot } from './page/to_match_image_snapshot.ts'\n\nlet browserContext: Awaited<typeof import('vitest/browser')>\nlet vitest: Awaited<typeof import('vitest')>\n\nif ((globalThis as any).__vitest_browser__) {\n\timport('vitest/browser').then((m) => {\n\t\tm.page.extend({ toMatchImageSnapshot })\n\t\tbrowserContext = m\n\t})\n\timport('vitest').then((m) => {\n\t\tvitest = m\n\t})\n}\n\nexport const page = new Proxy<BrowserPage>({} as any, {\n\tget(_target, prop) {\n\t\tconst r = (browserContext?.page as any)?.[prop]\n\t\tif (prop === 'toMatchImageSnapshot' && r === undefined) {\n\t\t\treturn () => {}\n\t\t}\n\t\treturn r\n\t},\n})\n\nexport const commands = new Proxy<BrowserCommands>({} as any, {\n\tget(_target, prop) {\n\t\treturn (browserContext?.commands as any)?.[prop]\n\t},\n})\n\nexport const getCurrentTest = () =>\n\tvitest?.TestRunner.getCurrentTest() as\n\t\t| (ReturnType<typeof vitest.TestRunner.getCurrentTest> & SnapshotTestMeta)\n\t\t| undefined\n","import type { AsyncExpectationResult } from '@vitest/expect'\nimport {\n\ttype ComparisonMethod,\n\ttype ToMatchImageSnapshotOptions,\n\tmatchImageSnapshotAction,\n\tsuccess,\n\ttoTaskId,\n} from 'vitest-plugin-vis/client-api'\nimport { commands, getCurrentTest } from '../vitest_proxy.ts'\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod>(\n\t/**\n\t * The element or locator to take the snapshot of,\n\t * or the base64 value of the image to compare against.\n\t */\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions<M> | undefined,\n): AsyncExpectationResult {\n\tconst test = getCurrentTest()\n\n\t/* v8 ignore start: stub as success when not in a test (e.g. in a story) */\n\tif (!test) return Promise.resolve(success)\n\t/* v8 ignore end */\n\n\treturn matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success)\n}\n","export function isSnapshotEnabled(tags: string[]) {\n\tconst noSnapshotIndex = tags.lastIndexOf('!snapshot')\n\tconst snapshotIndex = tags.lastIndexOf('snapshot')\n\n\tif (noSnapshotIndex < 0 && snapshotIndex < 0) return false\n\n\treturn noSnapshotIndex < snapshotIndex\n}\n","import { isRunningInTest } from '@repobuddy/test'\nimport type { NamedOrDefaultProjectAnnotations } from 'storybook/internal/types'\nimport { expect } from 'storybook/test'\nimport { setAutoSnapshotOptions } from 'vitest-plugin-vis'\nimport { toMatchImageSnapshot } from '../client/expect/to_match_image_snapshot.ts'\nimport { isSnapshotEnabled } from '../client/storybook/tags.ts'\nimport { getCurrentTest } from '../client/vitest_proxy.ts'\n\nlet extended = false\n\nexport const visAnnotations = {\n\tbeforeEach(ctx) {\n\t\tif (!isRunningInTest()) return\n\t\tif (!extended) {\n\t\t\texpect.extend({ toMatchImageSnapshot })\n\t\t\textended = true\n\t\t}\n\t\tconst test = getCurrentTest()\n\n\t\tsetAutoSnapshotOptions({\n\t\t\tenable: isSnapshotEnabled(ctx.tags),\n\t\t\t...ctx.parameters?.snapshot,\n\t\t\ttags: ctx.tags,\n\t\t\t...test?.meta.vis,\n\t\t})\n\t},\n} satisfies NamedOrDefaultProjectAnnotations<any>\n"],"mappings":";;;;;;AAQA,SAAgBA,uBACf,SACC;CACD,MAAM,OAAO,gBAAgB;;AAG7B,KAAI,CAAC,KAAM,QAAO,QAAQ,SAAS;;AAGnC,QAAO,6BAA6B,UAAU,SAAS,KAAK,EAAE,QAAQ;;;;;ACbvE,IAAI;AACJ,IAAI;AAEJ,IAAK,WAAmB,oBAAoB;AAC3C,QAAO,kBAAkB,MAAM,MAAM;AACpC,IAAE,KAAK,OAAO,EAAE,8CAAsB,CAAC;AACvC,mBAAiB;GAChB;AACF,QAAO,UAAU,MAAM,MAAM;AAC5B,WAAS;GACR;;AAGH,MAAa,OAAO,IAAI,MAAmB,EAAE,EAAS,EACrD,IAAI,SAAS,MAAM;CAClB,MAAM,KAAK,gBAAgB,QAAe;AAC1C,KAAI,SAAS,0BAA0B,MAAM,OAC5C,cAAa;AAEd,QAAO;GAER,CAAC;AAEF,MAAa,WAAW,IAAI,MAAuB,EAAE,EAAS,EAC7D,IAAI,SAAS,MAAM;AAClB,SAAQ,gBAAgB,YAAmB;GAE5C,CAAC;AAEF,MAAa,uBACZ,QAAQ,WAAW,gBAAgB;;;;ACxBpC,SAAgB,qBAKf,SACA,SACyB;CACzB,MAAM,OAAO,gBAAgB;;AAG7B,KAAI,CAAC,KAAM,QAAO,QAAQ,QAAQ,QAAQ;;AAG1C,QAAO,yBAAyB,UAAU,SAAS,KAAK,EAAE,SAAS,QAAQ,CAAC,WAAW,QAAQ;;;;;ACxBhG,SAAgB,kBAAkB,MAAgB;CACjD,MAAM,kBAAkB,KAAK,YAAY,YAAY;CACrD,MAAM,gBAAgB,KAAK,YAAY,WAAW;AAElD,KAAI,kBAAkB,KAAK,gBAAgB,EAAG,QAAO;AAErD,QAAO,kBAAkB;;;;;ACE1B,IAAI,WAAW;AAEf,MAAa,iBAAiB,EAC7B,WAAW,KAAK;AACf,KAAI,CAAC,iBAAiB,CAAE;AACxB,KAAI,CAAC,UAAU;AACd,SAAO,OAAO,EAAE,sBAAsB,CAAC;AACvC,aAAW;;CAEZ,MAAM,OAAO,gBAAgB;AAE7B,0BAAuB;EACtB,QAAQ,kBAAkB,IAAI,KAAK;EACnC,GAAG,IAAI,YAAY;EACnB,MAAM,IAAI;EACV,GAAG,MAAM,KAAK;EACd,CAAC;GAEH"}
@@ -1 +1 @@
1
- {"version":3,"file":"vis_annotation-N0xbuXis.d.mts","names":[],"sources":["../src/preview/vis_annotation.ts"],"sourcesContent":[],"mappings":";;;cASa;kBAeoC,uBAAA,CAAA,kBAAA,uBAAA,CAAA,IAAA"}
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"}
package/manager.js CHANGED
@@ -1,2 +1,2 @@
1
- import './dist/exports/manager.js';
1
+ import './dist/manager.js';
2
2
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-vis",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Storybook Vitest visual testing addon",
5
5
  "keywords": [
6
6
  "image-snapshot",
@@ -35,6 +35,11 @@
35
35
  "types": "./dist/index.d.mts",
36
36
  "default": "./dist/index.mjs"
37
37
  },
38
+ "./manager": {
39
+ "source": "./src/exports/manager.tsx",
40
+ "types": "./dist/manager.d.ts",
41
+ "default": "./dist/manager.js"
42
+ },
38
43
  "./*": {
39
44
  "source": "./src/exports/*.ts",
40
45
  "types": "./dist/exports/*.d.mts",
@@ -51,6 +56,7 @@
51
56
  "!**/*.{spec,test,unit,accept,integrate,system,perf,stress,stories,study}.*"
52
57
  ],
53
58
  "dependencies": {
59
+ "@repobuddy/test": "^1.0.1",
54
60
  "@storybook/icons": "^2.0.0",
55
61
  "glob": "^13.0.0",
56
62
  "is-ci": "^4.1.0",
@@ -1,3 +1,4 @@
1
+ import { isRunningInTest } from '@repobuddy/test'
1
2
  import type { NamedOrDefaultProjectAnnotations } from 'storybook/internal/types'
2
3
  import { expect } from 'storybook/test'
3
4
  import { setAutoSnapshotOptions } from 'vitest-plugin-vis'
@@ -9,6 +10,7 @@ let extended = false
9
10
 
10
11
  export const visAnnotations = {
11
12
  beforeEach(ctx) {
13
+ if (!isRunningInTest()) return
12
14
  if (!extended) {
13
15
  expect.extend({ toMatchImageSnapshot })
14
16
  extended = true