storybook-addon-vis 1.0.2 → 1.1.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/dist/chunk-4NIDZI2O.js +55 -0
- package/dist/chunk-4NIDZI2O.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -2
- package/dist/vitest-setup.js +1 -1
- package/package.json +3 -3
- package/src/client/page/to_match_image_snapshot.ts +19 -0
- package/src/client/vitest_proxy.ts +13 -1
- package/src/index.ts +4 -0
- package/dist/chunk-O5DYZDLL.js +0 -37
- package/dist/chunk-O5DYZDLL.js.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { matchPageImageSnapshotAction, toTaskId, success, matchImageSnapshotAction } from 'vitest-plugin-vis/client-api';
|
|
2
|
+
import { expect } from '@storybook/test';
|
|
3
|
+
|
|
4
|
+
// src/client/page/to_match_image_snapshot.ts
|
|
5
|
+
function toMatchImageSnapshot(options) {
|
|
6
|
+
const test = getCurrentTest();
|
|
7
|
+
if (!test) return Promise.resolve();
|
|
8
|
+
return matchPageImageSnapshotAction(commands, toTaskId(test), options);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/client/vitest_proxy.ts
|
|
12
|
+
var browserContext;
|
|
13
|
+
var vitestSuite;
|
|
14
|
+
if (globalThis.__vitest_browser__) {
|
|
15
|
+
import('@vitest/browser/context').then((m) => {
|
|
16
|
+
m.page.extend({ toMatchImageSnapshot });
|
|
17
|
+
browserContext = m;
|
|
18
|
+
});
|
|
19
|
+
import('vitest/suite').then((m) => {
|
|
20
|
+
vitestSuite = m;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
var page = new Proxy({}, {
|
|
24
|
+
get(_target, prop) {
|
|
25
|
+
const r = browserContext?.page?.[prop];
|
|
26
|
+
if (prop === "toMatchImageSnapshot" && r === void 0) {
|
|
27
|
+
return () => {
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return r;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var commands = new Proxy({}, {
|
|
34
|
+
get(_target, prop) {
|
|
35
|
+
return browserContext?.commands?.[prop];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var getCurrentTest = () => vitestSuite?.getCurrentTest();
|
|
39
|
+
function toMatchImageSnapshot2(subject, options) {
|
|
40
|
+
const test = getCurrentTest();
|
|
41
|
+
if (!test) return Promise.resolve(success);
|
|
42
|
+
return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/client/storybook/expect_extend.ts
|
|
46
|
+
expect.extend({ toMatchImageSnapshot: toMatchImageSnapshot2 });
|
|
47
|
+
|
|
48
|
+
// src/client/storybook/tags.ts
|
|
49
|
+
function isSnapshotEnabled(tags) {
|
|
50
|
+
return tags.lastIndexOf("!snapshot") < tags.lastIndexOf("snapshot");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { commands, getCurrentTest, isSnapshotEnabled, page };
|
|
54
|
+
//# sourceMappingURL=chunk-4NIDZI2O.js.map
|
|
55
|
+
//# sourceMappingURL=chunk-4NIDZI2O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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/expect_extend.ts","../src/client/storybook/tags.ts"],"names":["toMatchImageSnapshot","toTaskId"],"mappings":";;;;AAQO,SAAS,qBACf,OACC,EAAA;AACD,EAAA,MAAM,OAAO,cAAe,EAAA;AAG5B,EAAA,IAAI,CAAC,IAAA,EAAa,OAAA,OAAA,CAAQ,OAAQ,EAAA;AAGlC,EAAA,OAAO,4BAA6B,CAAA,QAAA,EAAU,QAAS,CAAA,IAAI,GAAG,OAAO,CAAA;AACtE;;;ACdA,IAAI,cAAA;AACJ,IAAI,WAAA;AAEJ,IAAK,WAAmB,kBAAoB,EAAA;AAC3C,EAAA,OAAO,yBAAyB,CAAA,CAAE,IAAK,CAAA,CAAC,CAAM,KAAA;AAC7C,IAAA,CAAA,CAAE,IAAK,CAAA,MAAA,CAAO,EAAE,oBAAA,EAAsB,CAAA;AACtC,IAAiB,cAAA,GAAA,CAAA;AAAA,GACjB,CAAA;AACD,EAAA,OAAO,cAAc,CAAA,CAAE,IAAK,CAAA,CAAC,CAAM,KAAA;AAClC,IAAc,WAAA,GAAA,CAAA;AAAA,GACd,CAAA;AACF;AAEO,IAAM,IAAO,GAAA,IAAI,KAAmB,CAAA,EAAW,EAAA;AAAA,EACrD,GAAA,CAAI,SAAS,IAAM,EAAA;AAClB,IAAM,MAAA,CAAA,GAAK,cAAgB,EAAA,IAAA,GAAe,IAAI,CAAA;AAC9C,IAAI,IAAA,IAAA,KAAS,sBAA0B,IAAA,CAAA,KAAM,MAAW,EAAA;AACvD,MAAA,OAAO,MAAM;AAAA,OAAC;AAAA;AAEf,IAAO,OAAA,CAAA;AAAA;AAET,CAAC;AAEM,IAAM,QAAW,GAAA,IAAI,KAAuB,CAAA,EAAW,EAAA;AAAA,EAC7D,GAAA,CAAI,SAAS,IAAM,EAAA;AAClB,IAAQ,OAAA,cAAA,EAAgB,WAAmB,IAAI,CAAA;AAAA;AAEjD,CAAC;AAEY,IAAA,cAAA,GAAiB,MAC7B,WAAA,EAAa,cAAe;ACxBtB,SAASA,qBAAAA,CAKf,SACA,OACyB,EAAA;AACzB,EAAA,MAAM,OAAO,cAAe,EAAA;AAG5B,EAAA,IAAI,CAAC,IAAA,EAAa,OAAA,OAAA,CAAQ,QAAQ,OAAO,CAAA;AAGzC,EAAO,OAAA,wBAAA,CAAyB,QAAUC,EAAAA,QAAAA,CAAS,IAAI,CAAA,EAAG,SAAS,OAAO,CAAA,CAAE,IAAK,CAAA,MAAM,OAAO,CAAA;AAC/F;;;ACtBA,MAAA,CAAO,MAAO,CAAA,EAAE,oBAAAD,EAAAA,qBAAAA,EAAsB,CAAA;;;ACH/B,SAAS,kBAAkB,IAAgB,EAAA;AACjD,EAAA,OAAO,KAAK,WAAY,CAAA,WAAW,CAAI,GAAA,IAAA,CAAK,YAAY,UAAU,CAAA;AACnE","file":"chunk-4NIDZI2O.js","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 { BrowserCommands, BrowserPage } from '@vitest/browser/context'\nimport type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'\nimport { toMatchImageSnapshot } from './page/to_match_image_snapshot.ts'\n\nlet browserContext: Awaited<typeof import('@vitest/browser/context')>\nlet vitestSuite: Awaited<typeof import('vitest/suite')>\n\nif ((globalThis as any).__vitest_browser__) {\n\timport('@vitest/browser/context').then((m) => {\n\t\tm.page.extend({ toMatchImageSnapshot })\n\t\tbrowserContext = m\n\t})\n\timport('vitest/suite').then((m) => {\n\t\tvitestSuite = 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\tvitestSuite?.getCurrentTest() as (ReturnType<typeof vitestSuite.getCurrentTest> & SnapshotTestMeta) | 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","import { expect } from '@storybook/test'\nimport { toMatchImageSnapshot } from '../expect/to_match_image_snapshot.ts'\n\nexpect.extend({ toMatchImageSnapshot })\n","export function isSnapshotEnabled(tags: string[]) {\n\treturn tags.lastIndexOf('!snapshot') < tags.lastIndexOf('snapshot')\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import './matcher.js';
|
|
2
|
+
import { BrowserPage } from '@vitest/browser/context';
|
|
2
3
|
export * from 'vitest-plugin-vis';
|
|
3
4
|
import { ImageSnapshotKeyOptions, ComparisonMethod, ToMatchImageSnapshotOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, SsimComparisonOptions, PixelComparisonOptions, FailureThresholdOptions } from 'vitest-plugin-vis/client-api';
|
|
4
5
|
export { ComparisonMethod, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotKeyOptions, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, PixelComparisonOptions, SsimComparisonOptions, ToMatchImageSnapshotOptions } from 'vitest-plugin-vis/client-api';
|
|
5
6
|
|
|
7
|
+
declare const page: BrowserPage;
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* Check if the snapshot image exists.
|
|
8
11
|
*/
|
|
@@ -42,4 +45,4 @@ type StorybookVisOptions = {
|
|
|
42
45
|
*/
|
|
43
46
|
declare function defineStorybookVisOptions(options: StorybookVisOptions): StorybookVisOptions;
|
|
44
47
|
|
|
45
|
-
export { type StorybookVisOptions, defineAutoSnapshotParam, defineStorybookVisOptions, hasImageSnapshot, isSnapshotEnabled };
|
|
48
|
+
export { type StorybookVisOptions, defineAutoSnapshotParam, defineStorybookVisOptions, hasImageSnapshot, isSnapshotEnabled, page };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getCurrentTest, commands } from './chunk-
|
|
2
|
-
export { isSnapshotEnabled } from './chunk-
|
|
1
|
+
import { getCurrentTest, commands } from './chunk-4NIDZI2O.js';
|
|
2
|
+
export { isSnapshotEnabled, page } from './chunk-4NIDZI2O.js';
|
|
3
3
|
export * from 'vitest-plugin-vis';
|
|
4
4
|
import { hasImageSnapshotAction, toTaskId } from 'vitest-plugin-vis/client-api';
|
|
5
5
|
|
package/dist/vitest-setup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commands, getCurrentTest, isSnapshotEnabled } from './chunk-
|
|
1
|
+
import { commands, getCurrentTest, isSnapshotEnabled } from './chunk-4NIDZI2O.js';
|
|
2
2
|
import { createVis } from 'vitest-plugin-vis/setup';
|
|
3
3
|
import { setAutoSnapshotOptions } from 'vitest-plugin-vis';
|
|
4
4
|
export { setAutoSnapshotOptions } from 'vitest-plugin-vis';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-vis",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Storybook Vitest visual testing addon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"image-snapshot",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"memoize": "^10.1.0",
|
|
68
68
|
"pathe": "^2.0.3",
|
|
69
69
|
"type-plus": "8.0.0-beta.7",
|
|
70
|
-
"vitest-plugin-vis": "^3.0
|
|
70
|
+
"vitest-plugin-vis": "^3.1.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@repobuddy/storybook": "^0.13.0",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"typescript": "^5.7.2",
|
|
104
104
|
"vite": "^6.2.3",
|
|
105
105
|
"vitest": "^3.0.9",
|
|
106
|
-
"vitest-browser-react": "^0.
|
|
106
|
+
"vitest-browser-react": "^0.2.0",
|
|
107
107
|
"webdriverio": "latest",
|
|
108
108
|
"zx": "^8.0.0"
|
|
109
109
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComparisonMethod,
|
|
3
|
+
type ToMatchPageImageSnapshotOptions,
|
|
4
|
+
matchPageImageSnapshotAction,
|
|
5
|
+
toTaskId,
|
|
6
|
+
} from 'vitest-plugin-vis/client-api'
|
|
7
|
+
import { commands, getCurrentTest } from '../vitest_proxy.ts'
|
|
8
|
+
|
|
9
|
+
export function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(
|
|
10
|
+
options?: ToMatchPageImageSnapshotOptions<M> | undefined,
|
|
11
|
+
) {
|
|
12
|
+
const test = getCurrentTest()
|
|
13
|
+
|
|
14
|
+
/* v8 ignore start: stub as success when not in a test (e.g. in a story) */
|
|
15
|
+
if (!test) return Promise.resolve()
|
|
16
|
+
/* v8 ignore end */
|
|
17
|
+
|
|
18
|
+
return matchPageImageSnapshotAction(commands, toTaskId(test), options)
|
|
19
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { BrowserCommands } from '@vitest/browser/context'
|
|
1
|
+
import type { BrowserCommands, BrowserPage } from '@vitest/browser/context'
|
|
2
2
|
import type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'
|
|
3
|
+
import { toMatchImageSnapshot } from './page/to_match_image_snapshot.ts'
|
|
3
4
|
|
|
4
5
|
let browserContext: Awaited<typeof import('@vitest/browser/context')>
|
|
5
6
|
let vitestSuite: Awaited<typeof import('vitest/suite')>
|
|
6
7
|
|
|
7
8
|
if ((globalThis as any).__vitest_browser__) {
|
|
8
9
|
import('@vitest/browser/context').then((m) => {
|
|
10
|
+
m.page.extend({ toMatchImageSnapshot })
|
|
9
11
|
browserContext = m
|
|
10
12
|
})
|
|
11
13
|
import('vitest/suite').then((m) => {
|
|
@@ -13,6 +15,16 @@ if ((globalThis as any).__vitest_browser__) {
|
|
|
13
15
|
})
|
|
14
16
|
}
|
|
15
17
|
|
|
18
|
+
export const page = new Proxy<BrowserPage>({} as any, {
|
|
19
|
+
get(_target, prop) {
|
|
20
|
+
const r = (browserContext?.page as any)?.[prop]
|
|
21
|
+
if (prop === 'toMatchImageSnapshot' && r === undefined) {
|
|
22
|
+
return () => {}
|
|
23
|
+
}
|
|
24
|
+
return r
|
|
25
|
+
},
|
|
26
|
+
})
|
|
27
|
+
|
|
16
28
|
export const commands = new Proxy<BrowserCommands>({} as any, {
|
|
17
29
|
get(_target, prop) {
|
|
18
30
|
return (browserContext?.commands as any)?.[prop]
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
import './client/storybook/expect_extend.ts'
|
|
3
3
|
import './shared/global_matcher_augment.ts'
|
|
4
4
|
|
|
5
|
+
import { page } from './client/vitest_proxy.ts'
|
|
6
|
+
|
|
5
7
|
export * from 'vitest-plugin-vis'
|
|
6
8
|
export * from './client/has_image_snapshot.ts'
|
|
7
9
|
export * from './client/storybook/param.ts'
|
|
8
10
|
export * from './client/storybook/tags.ts'
|
|
9
11
|
export * from './server/vis_options.ts'
|
|
12
|
+
|
|
13
|
+
export { page }
|
package/dist/chunk-O5DYZDLL.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { expect } from '@storybook/test';
|
|
2
|
-
import { success, matchImageSnapshotAction, toTaskId } from 'vitest-plugin-vis/client-api';
|
|
3
|
-
|
|
4
|
-
// src/client/vitest_proxy.ts
|
|
5
|
-
var browserContext;
|
|
6
|
-
var vitestSuite;
|
|
7
|
-
if (globalThis.__vitest_browser__) {
|
|
8
|
-
import('@vitest/browser/context').then((m) => {
|
|
9
|
-
browserContext = m;
|
|
10
|
-
});
|
|
11
|
-
import('vitest/suite').then((m) => {
|
|
12
|
-
vitestSuite = m;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
var commands = new Proxy({}, {
|
|
16
|
-
get(_target, prop) {
|
|
17
|
-
return browserContext?.commands?.[prop];
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
var getCurrentTest = () => vitestSuite?.getCurrentTest();
|
|
21
|
-
function toMatchImageSnapshot(subject, options) {
|
|
22
|
-
const test = getCurrentTest();
|
|
23
|
-
if (!test) return Promise.resolve(success);
|
|
24
|
-
return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// src/client/storybook/expect_extend.ts
|
|
28
|
-
expect.extend({ toMatchImageSnapshot });
|
|
29
|
-
|
|
30
|
-
// src/client/storybook/tags.ts
|
|
31
|
-
function isSnapshotEnabled(tags) {
|
|
32
|
-
return tags.lastIndexOf("!snapshot") < tags.lastIndexOf("snapshot");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { commands, getCurrentTest, isSnapshotEnabled };
|
|
36
|
-
//# sourceMappingURL=chunk-O5DYZDLL.js.map
|
|
37
|
-
//# sourceMappingURL=chunk-O5DYZDLL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client/vitest_proxy.ts","../src/client/expect/to_match_image_snapshot.ts","../src/client/storybook/expect_extend.ts","../src/client/storybook/tags.ts"],"names":[],"mappings":";;;;AAGA,IAAI,cAAA;AACJ,IAAI,WAAA;AAEJ,IAAK,WAAmB,kBAAoB,EAAA;AAC3C,EAAA,OAAO,yBAAyB,CAAA,CAAE,IAAK,CAAA,CAAC,CAAM,KAAA;AAC7C,IAAiB,cAAA,GAAA,CAAA;AAAA,GACjB,CAAA;AACD,EAAA,OAAO,cAAc,CAAA,CAAE,IAAK,CAAA,CAAC,CAAM,KAAA;AAClC,IAAc,WAAA,GAAA,CAAA;AAAA,GACd,CAAA;AACF;AAEO,IAAM,QAAW,GAAA,IAAI,KAAuB,CAAA,EAAW,EAAA;AAAA,EAC7D,GAAA,CAAI,SAAS,IAAM,EAAA;AAClB,IAAQ,OAAA,cAAA,EAAgB,WAAmB,IAAI,CAAA;AAAA;AAEjD,CAAC;AAEY,IAAA,cAAA,GAAiB,MAC7B,WAAA,EAAa,cAAe;ACZtB,SAAS,oBAAA,CAKf,SACA,OACyB,EAAA;AACzB,EAAA,MAAM,OAAO,cAAe,EAAA;AAG5B,EAAA,IAAI,CAAC,IAAA,EAAa,OAAA,OAAA,CAAQ,QAAQ,OAAO,CAAA;AAGzC,EAAO,OAAA,wBAAA,CAAyB,QAAU,EAAA,QAAA,CAAS,IAAI,CAAA,EAAG,SAAS,OAAO,CAAA,CAAE,IAAK,CAAA,MAAM,OAAO,CAAA;AAC/F;;;ACtBA,MAAO,CAAA,MAAA,CAAO,EAAE,oBAAA,EAAsB,CAAA;;;ACH/B,SAAS,kBAAkB,IAAgB,EAAA;AACjD,EAAA,OAAO,KAAK,WAAY,CAAA,WAAW,CAAI,GAAA,IAAA,CAAK,YAAY,UAAU,CAAA;AACnE","file":"chunk-O5DYZDLL.js","sourcesContent":["import type { BrowserCommands } from '@vitest/browser/context'\nimport type { SnapshotTestMeta } from 'vitest-plugin-vis/client-api'\n\nlet browserContext: Awaited<typeof import('@vitest/browser/context')>\nlet vitestSuite: Awaited<typeof import('vitest/suite')>\n\nif ((globalThis as any).__vitest_browser__) {\n\timport('@vitest/browser/context').then((m) => {\n\t\tbrowserContext = m\n\t})\n\timport('vitest/suite').then((m) => {\n\t\tvitestSuite = m\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\tvitestSuite?.getCurrentTest() as (ReturnType<typeof vitestSuite.getCurrentTest> & SnapshotTestMeta) | 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","import { expect } from '@storybook/test'\nimport { toMatchImageSnapshot } from '../expect/to_match_image_snapshot.ts'\n\nexpect.extend({ toMatchImageSnapshot })\n","export function isSnapshotEnabled(tags: string[]) {\n\treturn tags.lastIndexOf('!snapshot') < tags.lastIndexOf('snapshot')\n}\n"]}
|