vitest-plugin-vis 2.2.0 → 2.3.1
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/esm/client/ctx.d.ts +2 -2
- package/esm/client/ctx.d.ts.map +1 -1
- package/esm/client/ctx.js +2 -2
- package/esm/client/expect/to_match_image_snapshot.d.ts +1 -1
- package/esm/client/expect/to_match_image_snapshot.d.ts.map +1 -1
- package/esm/client/expect/to_match_image_snapshot.types.d.ts +1 -8
- package/esm/client/expect/to_match_image_snapshot.types.d.ts.map +1 -1
- package/esm/client/image_snapshot_matcher.d.ts +3 -3
- package/esm/client/image_snapshot_matcher.d.ts.map +1 -1
- package/esm/client/image_snapshot_matcher.js +7 -3
- package/esm/client/image_snapshot_matcher.logic.d.ts +1 -1
- package/esm/client/image_snapshot_matcher.logic.d.ts.map +1 -1
- package/esm/client/page/has_image_snapshot.d.ts.map +1 -1
- package/esm/client/page/has_image_snapshot.js +3 -2
- package/esm/client/should_take_snapshot.d.ts +1 -1
- package/esm/client/should_take_snapshot.d.ts.map +1 -1
- package/esm/client/should_take_snapshot.js +2 -2
- package/esm/client/snapshot_options.d.ts +2 -7
- package/esm/client/snapshot_options.d.ts.map +1 -1
- package/esm/client/snapshot_options.js +3 -6
- package/esm/client/vitest_suite_proxy.d.ts +12 -1
- package/esm/client/vitest_suite_proxy.d.ts.map +1 -1
- package/esm/client.d.ts +1 -1
- package/esm/client.d.ts.map +1 -1
- package/esm/config/vis.d.ts +3 -3
- package/esm/index.d.ts +2 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/server/commands/extend.d.ts +3 -3
- package/esm/server/commands/has_image_snapshot.d.ts +6 -2
- package/esm/server/commands/has_image_snapshot.d.ts.map +1 -1
- package/esm/server/commands/has_image_snapshot.js +2 -2
- package/esm/server/commands/match_image_snapshot.d.ts +2 -1
- package/esm/server/commands/match_image_snapshot.d.ts.map +1 -1
- package/esm/server/commands/match_image_snapshot.js +2 -2
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts +2 -1
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +1 -1
- package/esm/server/commands/prepare_image_snapshot_comparison.js +2 -2
- package/esm/server/vis_context.d.ts +3 -3
- package/esm/server/vis_context.d.ts.map +1 -1
- package/esm/server/vis_context.logic.d.ts +3 -3
- package/esm/server/vis_context.logic.d.ts.map +1 -1
- package/esm/server/vis_context.logic.js +8 -7
- package/esm/setup/create_vis.d.ts +5 -5
- package/esm/setup/create_vis.d.ts.map +1 -1
- package/esm/setup/create_vis.js +6 -5
- package/esm/setup/vis.d.ts +1 -1
- package/esm/setup/vis.d.ts.map +1 -1
- package/esm/shared/types.d.ts +12 -0
- package/esm/shared/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/readme.md +4 -3
- package/src/client/ctx.ts +2 -2
- package/src/client/expect/to_match_image_snapshot.ts +1 -1
- package/src/client/expect/to_match_image_snapshot.types.ts +1 -16
- package/src/client/image_snapshot_matcher.logic.ts +1 -1
- package/src/client/image_snapshot_matcher.ts +15 -5
- package/src/client/page/has_image_snapshot.ts +9 -2
- package/src/client/should_take_snapshot.ts +3 -2
- package/src/client/snapshot_options.ts +6 -14
- package/src/client/vitest_suite_proxy.ts +8 -1
- package/src/client.ts +1 -1
- package/src/index.ts +2 -1
- package/src/server/commands/has_image_snapshot.ts +5 -7
- package/src/server/commands/match_image_snapshot.ts +4 -3
- package/src/server/commands/prepare_image_snapshot_comparison.ts +4 -3
- package/src/server/vis_context.logic.ts +18 -8
- package/src/setup/create_vis.ts +19 -17
- package/src/shared/types.ts +18 -2
package/esm/client/ctx.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const ctx: {
|
|
2
|
-
autoEnabled: boolean;
|
|
3
|
-
getCurrentTest: () => import("
|
|
2
|
+
autoEnabled: boolean | undefined;
|
|
3
|
+
getCurrentTest: () => import("./vitest_suite_proxy.ts").CurrentTest;
|
|
4
4
|
getCurrentSuite: () => import("vitest").SuiteCollector<object>;
|
|
5
5
|
__test__reset(): void;
|
|
6
6
|
};
|
package/esm/client/ctx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ctx.d.ts","sourceRoot":"","sources":["../../src/client/ctx.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"ctx.d.ts","sourceRoot":"","sources":["../../src/client/ctx.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG;iBACW,OAAO,GAAG,SAAS;;;;CAQ7C,CAAA"}
|
package/esm/client/ctx.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getCurrentSuite, getCurrentTest } from "./vitest_suite_proxy.js";
|
|
2
2
|
export const ctx = {
|
|
3
|
-
autoEnabled:
|
|
3
|
+
autoEnabled: undefined,
|
|
4
4
|
getCurrentTest,
|
|
5
5
|
getCurrentSuite,
|
|
6
6
|
__test__reset() {
|
|
7
7
|
ctx.getCurrentTest = getCurrentTest;
|
|
8
8
|
ctx.getCurrentSuite = getCurrentSuite;
|
|
9
|
-
ctx.autoEnabled =
|
|
9
|
+
ctx.autoEnabled = undefined;
|
|
10
10
|
},
|
|
11
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AsyncExpectationResult } from '@vitest/expect';
|
|
2
|
-
import type { ToMatchImageSnapshotOptions } from '
|
|
2
|
+
import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
|
|
3
3
|
export declare function toMatchImageSnapshot(
|
|
4
4
|
/**
|
|
5
5
|
* The element or locator to take the snapshot of,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to_match_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"to_match_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAKxE,wBAAgB,oBAAoB;AACnC;;;GAGG;AACH,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,2BAA2B,GAAG,SAAS,GAC/C,sBAAsB,CAcxB"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import type { ComparisonMethod,
|
|
1
|
+
import type { ComparisonMethod, ToMatchImageSnapshotOptions } from '../../shared/types.ts';
|
|
2
2
|
export interface ImageSnapshotMatcher {
|
|
3
3
|
toMatchImageSnapshot<M extends ComparisonMethod>(options?: ToMatchImageSnapshotOptions<M> | undefined): Promise<void>;
|
|
4
4
|
}
|
|
5
|
-
export type ToMatchImageSnapshotOptions<M extends ComparisonMethod = 'pixel'> = ImageSnapshotTimeoutOptions & ImageSnapshotIdOptions & ImageSnapshotCompareOptions<M> & {
|
|
6
|
-
/**
|
|
7
|
-
* Expect the matcher to fail.
|
|
8
|
-
* If it passes, it will throw an error with details.
|
|
9
|
-
*/
|
|
10
|
-
expectToFail?: boolean | undefined;
|
|
11
|
-
};
|
|
12
5
|
//# sourceMappingURL=to_match_image_snapshot.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to_match_image_snapshot.types.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"to_match_image_snapshot.types.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAE1F,MAAM,WAAW,oBAAoB;IACpC,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,EAAE,OAAO,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrH"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Task } from 'vitest';
|
|
2
1
|
import type { ImageSnapshotNextIndexCommand } from '../commands.ts';
|
|
3
2
|
import type { PrepareImageSnapshotComparisonCommand } from '../server/commands/prepare_image_snapshot_comparison.ts';
|
|
4
3
|
import type { WriteImageSnapshotCommand } from '../server/commands/write_image_snapshot.ts';
|
|
5
|
-
import type { ToMatchImageSnapshotOptions } from '
|
|
6
|
-
|
|
4
|
+
import type { ToMatchImageSnapshotOptions } from '../shared/types.ts';
|
|
5
|
+
import type { CurrentTest } from './vitest_suite_proxy.ts';
|
|
6
|
+
export declare function imageSnapshotMatcher(commands: PrepareImageSnapshotComparisonCommand & WriteImageSnapshotCommand & ImageSnapshotNextIndexCommand): (test: CurrentTest & {}, subject: any, options?: ToMatchImageSnapshotOptions<any>) => Promise<void>;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated internalized. Use `matchImageSnapshot` directly instead.
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image_snapshot_matcher.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_matcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image_snapshot_matcher.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_matcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,yDAAyD,CAAA;AACpH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAG3F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAOrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,qCAAqC,GAAG,yBAAyB,GAAG,6BAA6B,UAGpG,WAAW,GAAG,EAAE,WACb,GAAG,YACF,2BAA2B,CAAC,GAAG,CAAC,mBAqE3C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,GAAG,OAOrD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isA } from '@vitest/expect';
|
|
1
2
|
import dedent from 'dedent';
|
|
2
3
|
import { resolve } from 'pathe';
|
|
3
4
|
import { isBase64String } from "../shared/base64.js";
|
|
@@ -10,8 +11,11 @@ import { toTaskId } from "./task_id.js";
|
|
|
10
11
|
import { server } from "./vitest_browser_context_proxy.js";
|
|
11
12
|
export function imageSnapshotMatcher(commands) {
|
|
12
13
|
return async function matchImageSnapshot(test, subject, options) {
|
|
14
|
+
const isAutoSnapshot = !!test.meta.vis?.isAutoSnapshot;
|
|
13
15
|
const taskId = toTaskId(test);
|
|
14
|
-
const info = await commands.prepareImageSnapshotComparison(taskId, parseImageSnapshotSubject(subject), options?.customizeSnapshotId
|
|
16
|
+
const info = await commands.prepareImageSnapshotComparison(taskId, parseImageSnapshotSubject(subject), isAutoSnapshot, options?.customizeSnapshotId
|
|
17
|
+
? await parseImageSnapshotOptions(commands, taskId, isAutoSnapshot, options)
|
|
18
|
+
: options);
|
|
15
19
|
if (!info)
|
|
16
20
|
return;
|
|
17
21
|
options = { ...info, ...options };
|
|
@@ -69,9 +73,9 @@ async function writeSnapshot(commands, path, image) {
|
|
|
69
73
|
const content = (await toDataURL(image)).split(',')[1];
|
|
70
74
|
return commands.writeImageSnapshot(path, content);
|
|
71
75
|
}
|
|
72
|
-
async function parseImageSnapshotOptions(commands, taskId, options) {
|
|
76
|
+
async function parseImageSnapshotOptions(commands, taskId, isAutoSnapshot, options) {
|
|
73
77
|
const index = await commands.imageSnapshotNextIndex(taskId);
|
|
74
78
|
const { customizeSnapshotId, ...rest } = options;
|
|
75
|
-
const snapshotFileId = customizeSnapshotId({ id: taskId, index });
|
|
79
|
+
const snapshotFileId = customizeSnapshotId({ id: taskId, index, isAutoSnapshot });
|
|
76
80
|
return { ...rest, snapshotFileId };
|
|
77
81
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ToMatchImageSnapshotOptions } from '
|
|
1
|
+
import type { ToMatchImageSnapshotOptions } from '../shared/types.ts';
|
|
2
2
|
export declare function prettifyOptions(options: ToMatchImageSnapshotOptions<any> | undefined): string;
|
|
3
3
|
//# sourceMappingURL=image_snapshot_matcher.logic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image_snapshot_matcher.logic.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_matcher.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"image_snapshot_matcher.logic.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_matcher.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAErE,wBAAgB,eAAe,CAAC,OAAO,EAAE,2BAA2B,CAAC,GAAG,CAAC,GAAG,SAAS,UAWpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/page/has_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,yBAAyB,CAAA;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAInE,MAAM,WAAW,sBAAsB;IACtC,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"has_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/page/has_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,yBAAyB,CAAA;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAInE,MAAM,WAAW,sBAAsB;IACtC,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACnG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,SAAS,oBA2B/F"}
|
|
@@ -14,10 +14,11 @@ export function hasImageSnapshot(options) {
|
|
|
14
14
|
"concurrent tests run at the same time in the same iframe and affect each other's environment. ");
|
|
15
15
|
}
|
|
16
16
|
const taskId = toTaskId(test);
|
|
17
|
+
const isAutoSnapshot = !!test.meta.vis?.isAutoSnapshot;
|
|
17
18
|
if (options?.customizeSnapshotId) {
|
|
18
19
|
return commands
|
|
19
20
|
.imageSnapshotNextIndex(taskId)
|
|
20
|
-
.then((index) => commands.hasImageSnapshot(taskId, options.customizeSnapshotId({ id: taskId, index })));
|
|
21
|
+
.then((index) => commands.hasImageSnapshot(taskId, options.customizeSnapshotId({ id: taskId, index, isAutoSnapshot }), isAutoSnapshot));
|
|
21
22
|
}
|
|
22
|
-
return commands.hasImageSnapshot(taskId);
|
|
23
|
+
return commands.hasImageSnapshot(taskId, undefined, isAutoSnapshot);
|
|
23
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"should_take_snapshot.d.ts","sourceRoot":"","sources":["../../src/client/should_take_snapshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"should_take_snapshot.d.ts","sourceRoot":"","sources":["../../src/client/should_take_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAItD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,SAAS,uBAGtE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ctx } from "./ctx.js";
|
|
2
|
-
import {
|
|
2
|
+
import { extractAutoSnapshotOptions } from "./snapshot_options.js";
|
|
3
3
|
/**
|
|
4
4
|
* Determine should snapshot be taken.
|
|
5
5
|
*
|
|
@@ -8,6 +8,6 @@ import { getAutoSnapshotOptions } from "./snapshot_options.js";
|
|
|
8
8
|
* disabled by `!snapshot` tag: false
|
|
9
9
|
*/
|
|
10
10
|
export function shouldTakeSnapshot(meta) {
|
|
11
|
-
const m = meta ??
|
|
11
|
+
const m = meta ?? extractAutoSnapshotOptions(ctx.getCurrentTest());
|
|
12
12
|
return document.body.childElementCount > 0 && m?.enable;
|
|
13
13
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ToMatchImageSnapshotOptions } from './expect/to_match_image_snapshot.types.ts';
|
|
3
|
-
export type SnapshotMeta<M extends ComparisonMethod> = ToMatchImageSnapshotOptions<M> & AutoSnapshotOptions & {
|
|
4
|
-
enable?: boolean | undefined;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
};
|
|
1
|
+
import type { ComparisonMethod, SnapshotMeta } from '../shared/types.ts';
|
|
7
2
|
type Suite = {
|
|
8
3
|
meta: Record<string, any>;
|
|
9
4
|
suite?: Suite | undefined;
|
|
@@ -33,6 +28,6 @@ export declare function enableAuto(): void;
|
|
|
33
28
|
*/
|
|
34
29
|
export declare function setAutoSnapshotOptions<M extends ComparisonMethod>(task: MetaTask, meta: SnapshotMeta<M> | boolean): void;
|
|
35
30
|
export declare function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: SnapshotMeta<M> | boolean): void;
|
|
36
|
-
export declare function
|
|
31
|
+
export declare function extractAutoSnapshotOptions<M extends SnapshotMeta<any> = SnapshotMeta<any>>(task: MetaTask): M | undefined;
|
|
37
32
|
export {};
|
|
38
33
|
//# sourceMappingURL=snapshot_options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot_options.d.ts","sourceRoot":"","sources":["../../src/client/snapshot_options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"snapshot_options.d.ts","sourceRoot":"","sources":["../../src/client/snapshot_options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAGxE,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,CAAA;AAErE,MAAM,MAAM,QAAQ,GACjB;IACA,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,SAAS,CAAA;IAChD,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACxB,GACD,SAAS,CAAA;AAEZ,wBAAgB,UAAU,SAEzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,gBAAgB,EAChE,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,GAC7B,IAAI,CAAA;AACP,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAAA;AAwBzG,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,EACzF,IAAI,EAAE,QAAQ,GACZ,CAAC,GAAG,SAAS,CAkBf"}
|
|
@@ -19,7 +19,7 @@ function parseArgs(args) {
|
|
|
19
19
|
function parseMeta(meta) {
|
|
20
20
|
return typeof meta === 'boolean' ? { enable: meta } : { enable: true, ...meta };
|
|
21
21
|
}
|
|
22
|
-
export function
|
|
22
|
+
export function extractAutoSnapshotOptions(task) {
|
|
23
23
|
if (!task)
|
|
24
24
|
return;
|
|
25
25
|
const list = [];
|
|
@@ -31,10 +31,7 @@ export function getAutoSnapshotOptions(task) {
|
|
|
31
31
|
list.unshift(task.file?.meta);
|
|
32
32
|
list.push(task.meta);
|
|
33
33
|
return list.reduce((acc, cur) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return Object.assign({}, acc, meta);
|
|
37
|
-
}
|
|
38
|
-
return acc;
|
|
34
|
+
const meta = cur?.[NAME];
|
|
35
|
+
return meta ? Object.assign({}, acc, meta) : acc;
|
|
39
36
|
}, { enable: ctx.autoEnabled });
|
|
40
37
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NAME } from '../shared/constants.ts';
|
|
2
|
+
import type { SnapshotMeta } from '../shared/types.ts';
|
|
3
|
+
declare let vitestSuite: Awaited<typeof import('vitest/suite')>;
|
|
4
|
+
export type CurrentTest = ReturnType<typeof vitestSuite.getCurrentTest> & {
|
|
5
|
+
meta: {
|
|
6
|
+
[NAME]?: SnapshotMeta<'pixel' | 'ssim'> & {
|
|
7
|
+
isAutoSnapshot?: boolean | undefined;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const getCurrentTest: () => CurrentTest;
|
|
2
12
|
export declare const getCurrentSuite: () => import("vitest").SuiteCollector<object>;
|
|
13
|
+
export {};
|
|
3
14
|
//# sourceMappingURL=vitest_suite_proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest_suite_proxy.d.ts","sourceRoot":"","sources":["../../src/client/vitest_suite_proxy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vitest_suite_proxy.d.ts","sourceRoot":"","sources":["../../src/client/vitest_suite_proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,QAAA,IAAI,WAAW,EAAE,OAAO,CAAC,cAAc,cAAc,CAAC,CAAC,CAAA;AAQvD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,cAAc,CAAC,GAAG;IACzE,IAAI,EAAE;QAAE,CAAC,IAAI,CAAC,CAAC,EAAE,YAAY,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG;YAAE,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;SAAE,CAAA;KAAE,CAAA;CAC5F,CAAA;AAED,eAAO,MAAM,cAAc,QAA0C,WAAW,CAAA;AAChF,eAAO,MAAM,eAAe,+CAAuC,CAAA"}
|
package/esm/client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './client/expect/expectation_result.ts';
|
|
|
2
2
|
export type * from './client/expect/to_match_image_snapshot.types.ts';
|
|
3
3
|
export * from './client/image_snapshot_matcher.ts';
|
|
4
4
|
export * from './client/should_take_snapshot.ts';
|
|
5
|
-
export {
|
|
5
|
+
export { setAutoSnapshotOptions, type MetaTask } from './client/snapshot_options.ts';
|
|
6
6
|
export * from './client/task_id.ts';
|
|
7
7
|
export type * from './shared/types.ts';
|
|
8
8
|
//# sourceMappingURL=client.d.ts.map
|
package/esm/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,mBAAmB,kDAAkD,CAAA;AACrE,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAA;AACrD,mBAAmB,kDAAkD,CAAA;AACrE,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACpF,cAAc,qBAAqB,CAAA;AACnC,mBAAmB,mBAAmB,CAAA"}
|
package/esm/config/vis.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export declare function vis<M extends ComparisonMethod = 'pixel'>(options?: VisO
|
|
|
15
15
|
commands: {
|
|
16
16
|
setupVisSuite: import("vitest/node").BrowserCommand<[]>;
|
|
17
17
|
imageSnapshotNextIndex: import("vitest/node").BrowserCommand<[taskId: string]>;
|
|
18
|
-
hasImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, snapshotId
|
|
19
|
-
matchImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, subject: string, options?: import("../commands.ts").MatchImageSnapshotOptions | undefined]>;
|
|
20
|
-
prepareImageSnapshotComparison: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string, options?: import("../commands.ts").MatchImageSnapshotOptions | undefined]>;
|
|
18
|
+
hasImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string | undefined, isAutoSnapshot: boolean]>;
|
|
19
|
+
matchImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, subject: string, isAutoSnapshot: boolean, options?: import("../commands.ts").MatchImageSnapshotOptions | undefined]>;
|
|
20
|
+
prepareImageSnapshotComparison: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string, isAutoSnapshot: boolean, options?: import("../commands.ts").MatchImageSnapshotOptions | undefined]>;
|
|
21
21
|
writeImageSnapshot: import("vitest/node").BrowserCommand<[relativeFilePath: string, imageBase64: string]>;
|
|
22
22
|
};
|
|
23
23
|
};
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import './client/expect/augment.ts';
|
|
2
2
|
import './client/page/augment.ts';
|
|
3
|
-
export {
|
|
3
|
+
export { setAutoSnapshotOptions, type MetaTask } from './client/snapshot_options.ts';
|
|
4
|
+
export type * from './shared/types.ts';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,4BAA4B,CAAA;AACnC,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,4BAA4B,CAAA;AACnC,OAAO,0BAA0B,CAAA;AAEjC,OAAO,EAAE,sBAAsB,EAAE,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACpF,mBAAmB,mBAAmB,CAAA"}
|
|
@@ -11,9 +11,9 @@ declare module '@vitest/browser/context' {
|
|
|
11
11
|
export declare const commands: {
|
|
12
12
|
setupVisSuite: import("vitest/node").BrowserCommand<[]>;
|
|
13
13
|
imageSnapshotNextIndex: import("vitest/node").BrowserCommand<[taskId: string]>;
|
|
14
|
-
hasImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, snapshotId
|
|
15
|
-
matchImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, subject: string, options?: import("./match_image_snapshot.ts").MatchImageSnapshotOptions | undefined]>;
|
|
16
|
-
prepareImageSnapshotComparison: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string, options?: import("./match_image_snapshot.ts").MatchImageSnapshotOptions | undefined]>;
|
|
14
|
+
hasImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string | undefined, isAutoSnapshot: boolean]>;
|
|
15
|
+
matchImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, subject: string, isAutoSnapshot: boolean, options?: import("./match_image_snapshot.ts").MatchImageSnapshotOptions | undefined]>;
|
|
16
|
+
prepareImageSnapshotComparison: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string, isAutoSnapshot: boolean, options?: import("./match_image_snapshot.ts").MatchImageSnapshotOptions | undefined]>;
|
|
17
17
|
writeImageSnapshot: import("vitest/node").BrowserCommand<[relativeFilePath: string, imageBase64: string]>;
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { BrowserCommand } from 'vitest/node';
|
|
2
2
|
export interface HasImageSnapshotCommand {
|
|
3
|
-
hasImageSnapshot(taskId: string, snapshotId
|
|
3
|
+
hasImageSnapshot(taskId: string, snapshotId: string | undefined, isAutoSnapshot: boolean): Promise<boolean>;
|
|
4
4
|
}
|
|
5
|
-
export declare const hasImageSnapshot: BrowserCommand<[
|
|
5
|
+
export declare const hasImageSnapshot: BrowserCommand<[
|
|
6
|
+
taskId: string,
|
|
7
|
+
snapshotId: string | undefined,
|
|
8
|
+
isAutoSnapshot: boolean
|
|
9
|
+
]>;
|
|
6
10
|
//# sourceMappingURL=has_image_snapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/server/commands/has_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,MAAM,WAAW,uBAAuB;IACvC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"has_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/server/commands/has_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,MAAM,WAAW,uBAAuB;IACvC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,cAAc,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC3G;AAED,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAC5C;IAAC,MAAM,EAAE,MAAM;IAAE,UAAU,EAAE,MAAM,GAAG,SAAS;IAAE,cAAc,EAAE,OAAO;CAAC,CAKzE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { visContext } from "../vis_context.js";
|
|
2
2
|
import { assertTestPathDefined } from "./_assertions.js";
|
|
3
|
-
export const hasImageSnapshot = async (context, taskId, snapshotId) => {
|
|
3
|
+
export const hasImageSnapshot = async (context, taskId, snapshotId, isAutoSnapshot) => {
|
|
4
4
|
assertTestPathDefined(context, 'hasImageSnapshot');
|
|
5
|
-
return visContext.hasImageSnapshot(context.testPath, taskId, snapshotId);
|
|
5
|
+
return visContext.hasImageSnapshot(context.testPath, taskId, snapshotId, isAutoSnapshot);
|
|
6
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BrowserCommand } from 'vitest/node';
|
|
2
2
|
import type { ImageSnapshotCompareOptions, ImageSnapshotIdOptions, ImageSnapshotTimeoutOptions } from '../../shared/types.ts';
|
|
3
3
|
export interface MatchImageSnapshotCommand {
|
|
4
|
-
matchImageSnapshot: (taskId: string | undefined, subject: string, options?: MatchImageSnapshotOptions | undefined) => Promise<void>;
|
|
4
|
+
matchImageSnapshot: (taskId: string | undefined, subject: string, isAutoSnapshot: boolean, options?: MatchImageSnapshotOptions | undefined) => Promise<void>;
|
|
5
5
|
}
|
|
6
6
|
export type MatchImageSnapshotOptions = ImageSnapshotTimeoutOptions & ImageSnapshotIdOptions & ImageSnapshotCompareOptions<any> & {
|
|
7
7
|
/**
|
|
@@ -12,6 +12,7 @@ export type MatchImageSnapshotOptions = ImageSnapshotTimeoutOptions & ImageSnaps
|
|
|
12
12
|
export declare const matchImageSnapshot: BrowserCommand<[
|
|
13
13
|
taskId: string,
|
|
14
14
|
subject: string,
|
|
15
|
+
isAutoSnapshot: boolean,
|
|
15
16
|
options?: MatchImageSnapshotOptions | undefined
|
|
16
17
|
]>;
|
|
17
18
|
//# sourceMappingURL=match_image_snapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/server/commands/match_image_snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAKjD,OAAO,KAAK,EACX,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,MAAM,uBAAuB,CAAA;AAM9B,MAAM,WAAW,yBAAyB;IACzC,kBAAkB,EAAE,CACnB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS,KAC3C,OAAO,CAAC,IAAI,CAAC,CAAA;CAClB;AAED,MAAM,MAAM,yBAAyB,GAAG,2BAA2B,GAClE,sBAAsB,GACtB,2BAA2B,CAAC,GAAG,CAAC,GAAG;IAClC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAC9C;IAAC,MAAM,EAAE,MAAM;IAAE,OAAO,EAAE,MAAM;IAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS;CAAC,
|
|
1
|
+
{"version":3,"file":"match_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/server/commands/match_image_snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAKjD,OAAO,KAAK,EACX,2BAA2B,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,MAAM,uBAAuB,CAAA;AAM9B,MAAM,WAAW,yBAAyB;IACzC,kBAAkB,EAAE,CACnB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,EACvB,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS,KAC3C,OAAO,CAAC,IAAI,CAAC,CAAA;CAClB;AAED,MAAM,MAAM,yBAAyB,GAAG,2BAA2B,GAClE,sBAAsB,GACtB,2BAA2B,CAAC,GAAG,CAAC,GAAG;IAClC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC,CAAA;AAEF,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAC9C;IAAC,MAAM,EAAE,MAAM;IAAE,OAAO,EAAE,MAAM;IAAE,cAAc,EAAE,OAAO;IAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS;CAAC,CAuE3G,CAAA"}
|
|
@@ -9,13 +9,13 @@ import { file } from "../file.js";
|
|
|
9
9
|
import { takeSnapshot, takeSnapshotByBrowser, writeSnapshot, writeSnapshotBuffer } from "../snapshot.js";
|
|
10
10
|
import { visContext } from "../vis_context.js";
|
|
11
11
|
import { assertTestPathDefined } from "./_assertions.js";
|
|
12
|
-
export const matchImageSnapshot = async (context, taskId, subject, options) => {
|
|
12
|
+
export const matchImageSnapshot = async (context, taskId, subject, isAutoSnapshot, options) => {
|
|
13
13
|
assertTestPathDefined(context, 'matchImageSnapshot');
|
|
14
14
|
// vitest:browser passes in `null` when not defined
|
|
15
15
|
if (!options)
|
|
16
16
|
options = {};
|
|
17
17
|
options.timeout = options.timeout ?? 30000;
|
|
18
|
-
const info = visContext.getSnapshotInfo(context.testPath, taskId, options);
|
|
18
|
+
const info = visContext.getSnapshotInfo(context.testPath, taskId, isAutoSnapshot, options);
|
|
19
19
|
const baselineBuffer = await file.tryReadFile(info.baselinePath);
|
|
20
20
|
if (!baselineBuffer) {
|
|
21
21
|
if (isBase64String(subject)) {
|
|
@@ -10,11 +10,12 @@ type ImageSnapshotComparisonInfo = {
|
|
|
10
10
|
result: string;
|
|
11
11
|
} & ImageSnapshotTimeoutOptions & FailureThresholdOptions & (SsimComparisonOptions | PixelComparisonOptions);
|
|
12
12
|
export interface PrepareImageSnapshotComparisonCommand {
|
|
13
|
-
prepareImageSnapshotComparison: (taskId: string | undefined, subject: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo | undefined>;
|
|
13
|
+
prepareImageSnapshotComparison: (taskId: string | undefined, subject: string, isAutoSnapshot: boolean, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo | undefined>;
|
|
14
14
|
}
|
|
15
15
|
export declare const prepareImageSnapshotComparison: BrowserCommand<[
|
|
16
16
|
taskId: string,
|
|
17
17
|
snapshotId: string,
|
|
18
|
+
isAutoSnapshot: boolean,
|
|
18
19
|
options?: MatchImageSnapshotOptions | undefined
|
|
19
20
|
]>;
|
|
20
21
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare_image_snapshot_comparison.d.ts","sourceRoot":"","sources":["../../../src/server/commands/prepare_image_snapshot_comparison.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,KAAK,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,uBAAuB,CAAA;AAK9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAE1E,KAAK,2BAA2B,GAAG;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACd,GAAG,2BAA2B,GAC9B,uBAAuB,GACvB,CAAC,qBAAqB,GAAG,sBAAsB,CAAC,CAAA;AAEjD,MAAM,WAAW,qCAAqC;IACrD,8BAA8B,EAAE,CAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS,KAC3C,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAAA;CACrD;AAED,eAAO,MAAM,8BAA8B,EAAE,cAAc,CAC1D;IAAC,MAAM,EAAE,MAAM;IAAE,UAAU,EAAE,MAAM;IAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS;CAAC,
|
|
1
|
+
{"version":3,"file":"prepare_image_snapshot_comparison.d.ts","sourceRoot":"","sources":["../../../src/server/commands/prepare_image_snapshot_comparison.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,KAAK,EACX,uBAAuB,EACvB,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,MAAM,uBAAuB,CAAA;AAK9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAE1E,KAAK,2BAA2B,GAAG;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACd,GAAG,2BAA2B,GAC9B,uBAAuB,GACvB,CAAC,qBAAqB,GAAG,sBAAsB,CAAC,CAAA;AAEjD,MAAM,WAAW,qCAAqC;IACrD,8BAA8B,EAAE,CAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,OAAO,EACvB,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS,KAC3C,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC,CAAA;CACrD;AAED,eAAO,MAAM,8BAA8B,EAAE,cAAc,CAC1D;IAAC,MAAM,EAAE,MAAM;IAAE,UAAU,EAAE,MAAM;IAAE,cAAc,EAAE,OAAO;IAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,SAAS;CAAC,CA0B9G,CAAA"}
|
|
@@ -3,13 +3,13 @@ import { file } from "../file.js";
|
|
|
3
3
|
import { takeSnapshot, takeSnapshotByBrowser, writeSnapshot } from "../snapshot.js";
|
|
4
4
|
import { visContext } from "../vis_context.js";
|
|
5
5
|
import { assertTestPathDefined } from "./_assertions.js";
|
|
6
|
-
export const prepareImageSnapshotComparison = async (context, taskId, subject, options) => {
|
|
6
|
+
export const prepareImageSnapshotComparison = async (context, taskId, subject, isAutoSnapshot, options) => {
|
|
7
7
|
assertTestPathDefined(context, 'prepareImageSnapshotComparison');
|
|
8
8
|
// vitest:browser passes in `null` when not defined
|
|
9
9
|
if (!options)
|
|
10
10
|
options = {};
|
|
11
11
|
options.timeout = options.timeout ?? 30000;
|
|
12
|
-
const info = visContext.getSnapshotInfo(context.testPath, taskId, options);
|
|
12
|
+
const info = visContext.getSnapshotInfo(context.testPath, taskId, isAutoSnapshot, options);
|
|
13
13
|
const baselineBuffer = await file.tryReadFile(info.baselinePath);
|
|
14
14
|
if (!baselineBuffer) {
|
|
15
15
|
if (isBase64String(subject)) {
|
|
@@ -4,7 +4,7 @@ export declare const visContext: {
|
|
|
4
4
|
__test__reset(): void;
|
|
5
5
|
__test__getState(): import("./vis_context.types.ts").VisState;
|
|
6
6
|
setupSuite(context: import("./vis_context.types.ts").PartialBrowserCommandContext): Promise<import("type-plus").Pick._<import("./vis_context.types.ts").VisState, "subjectDataTestId">>;
|
|
7
|
-
getSnapshotInfo(testPath: string, name: string, options?: {
|
|
7
|
+
getSnapshotInfo(testPath: string, name: string, isAutoSnapshot: boolean, options?: {
|
|
8
8
|
snapshotFileId?: string | undefined;
|
|
9
9
|
}): {
|
|
10
10
|
baselinePath: string;
|
|
@@ -34,13 +34,13 @@ export declare const visContext: {
|
|
|
34
34
|
} | undefined;
|
|
35
35
|
};
|
|
36
36
|
getTaskCount(testPath: string, taskId: string): number;
|
|
37
|
-
hasImageSnapshot(testPath: string, taskId: string, snapshotFileId: string | undefined): Promise<boolean>;
|
|
37
|
+
hasImageSnapshot(testPath: string, taskId: string, snapshotFileId: string | undefined, isAutoSnapshot: boolean): Promise<boolean>;
|
|
38
38
|
getSnapshotFilename(info: {
|
|
39
39
|
taskId: string;
|
|
40
40
|
task: {
|
|
41
41
|
count: number;
|
|
42
42
|
};
|
|
43
|
-
}, snapshotFileId: string | undefined): string;
|
|
43
|
+
}, snapshotFileId: string | undefined, isAutoSnapshot: boolean): string;
|
|
44
44
|
getSuiteInfo(testPath: string, taskId: string): {
|
|
45
45
|
suiteId: string;
|
|
46
46
|
taskId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;
|
|
1
|
+
{"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;sBACmgD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD/+C,CAAA"}
|
|
@@ -11,7 +11,7 @@ export declare function createVisContext(): {
|
|
|
11
11
|
* It needs to make sure there is no race condition between the test files.
|
|
12
12
|
*/
|
|
13
13
|
setupSuite(context: PartialBrowserCommandContext): Promise<import("type-plus").Pick._<VisState, "subjectDataTestId">>;
|
|
14
|
-
getSnapshotInfo(testPath: string, name: string, options?: {
|
|
14
|
+
getSnapshotInfo(testPath: string, name: string, isAutoSnapshot: boolean, options?: {
|
|
15
15
|
snapshotFileId?: string | undefined;
|
|
16
16
|
}): {
|
|
17
17
|
baselinePath: string;
|
|
@@ -41,13 +41,13 @@ export declare function createVisContext(): {
|
|
|
41
41
|
} | undefined;
|
|
42
42
|
};
|
|
43
43
|
getTaskCount(testPath: string, taskId: string): number;
|
|
44
|
-
hasImageSnapshot(testPath: string, taskId: string, snapshotFileId: string | undefined): Promise<boolean>;
|
|
44
|
+
hasImageSnapshot(testPath: string, taskId: string, snapshotFileId: string | undefined, isAutoSnapshot: boolean): Promise<boolean>;
|
|
45
45
|
getSnapshotFilename(info: {
|
|
46
46
|
taskId: string;
|
|
47
47
|
task: {
|
|
48
48
|
count: number;
|
|
49
49
|
};
|
|
50
|
-
}, snapshotFileId: string | undefined): string;
|
|
50
|
+
}, snapshotFileId: string | undefined, isAutoSnapshot: boolean): string;
|
|
51
51
|
getSuiteInfo(testPath: string, taskId: string): {
|
|
52
52
|
suiteId: string;
|
|
53
53
|
taskId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.logic.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.logic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAKpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEpF,wBAAgB,gBAAgB;eAMnB,CAAC,SAAS,OAAO,GAAG,MAAM,YAAW,UAAU,CAAC,CAAC,CAAC;;;;IAY7D;;;;OAIG;wBACuB,4BAA4B;
|
|
1
|
+
{"version":3,"file":"vis_context.logic.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.logic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAKpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAEpF,wBAAgB,gBAAgB;eAMnB,CAAC,SAAS,OAAO,GAAG,MAAM,YAAW,UAAU,CAAC,CAAC,CAAC;;;;IAY7D;;;;OAIG;wBACuB,4BAA4B;8BAc3C,MAAM,QACV,MAAM,kBACI,OAAO,YACb;QAAE,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAmB3B,MAAM,UAAU,MAAM;+BAGlB,MAAM,UAAU,MAAM,kBAAkB,MAAM,GAAG,SAAS,kBAAkB,OAAO;8BAKvG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,kBAEjC,MAAM,GAAG,SAAS,kBAClB,OAAO;2BAUD,MAAM,UAAU,MAAM;;;;;;;;;;EAe9C;AAyBD,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC;;;;;;;;EAWnH;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC,UAElH"}
|
|
@@ -39,10 +39,10 @@ export function createVisContext() {
|
|
|
39
39
|
await Promise.allSettled([ctx.rimraf(suite.diffDir), ctx.rimraf(suite.resultDir)]);
|
|
40
40
|
return pick(state, 'subjectDataTestId');
|
|
41
41
|
},
|
|
42
|
-
getSnapshotInfo(testPath, name, options) {
|
|
43
|
-
const
|
|
44
|
-
const snapshotFilename = context.getSnapshotFilename(
|
|
45
|
-
const { baselineDir, resultDir, diffDir, task } =
|
|
42
|
+
getSnapshotInfo(testPath, name, isAutoSnapshot, options) {
|
|
43
|
+
const suiteInfo = context.getSuiteInfo(testPath, name);
|
|
44
|
+
const snapshotFilename = context.getSnapshotFilename(suiteInfo, options?.snapshotFileId, isAutoSnapshot);
|
|
45
|
+
const { baselineDir, resultDir, diffDir, task } = suiteInfo;
|
|
46
46
|
task.count = task.count + 1;
|
|
47
47
|
const baselinePath = join(baselineDir, snapshotFilename);
|
|
48
48
|
const resultPath = join(resultDir, snapshotFilename);
|
|
@@ -57,17 +57,18 @@ export function createVisContext() {
|
|
|
57
57
|
getTaskCount(testPath, taskId) {
|
|
58
58
|
return context.getSuiteInfo(testPath, taskId).task.count;
|
|
59
59
|
},
|
|
60
|
-
hasImageSnapshot(testPath, taskId, snapshotFileId) {
|
|
60
|
+
hasImageSnapshot(testPath, taskId, snapshotFileId, isAutoSnapshot) {
|
|
61
61
|
const info = context.getSuiteInfo(testPath, taskId);
|
|
62
|
-
return file.existFile(join(info.baselineDir, context.getSnapshotFilename(info, snapshotFileId)));
|
|
62
|
+
return file.existFile(join(info.baselineDir, context.getSnapshotFilename(info, snapshotFileId, isAutoSnapshot)));
|
|
63
63
|
},
|
|
64
|
-
getSnapshotFilename(info, snapshotFileId) {
|
|
64
|
+
getSnapshotFilename(info, snapshotFileId, isAutoSnapshot) {
|
|
65
65
|
if (snapshotFileId)
|
|
66
66
|
return `${snapshotFileId}.png`;
|
|
67
67
|
const customizeSnapshotId = visOptions.customizeSnapshotId ?? (({ id, index }) => `${id}-${index}`);
|
|
68
68
|
return `${customizeSnapshotId({
|
|
69
69
|
id: info.taskId,
|
|
70
70
|
index: info.task.count,
|
|
71
|
+
isAutoSnapshot,
|
|
71
72
|
})}.png`;
|
|
72
73
|
},
|
|
73
74
|
getSuiteInfo(testPath, taskId) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type SnapshotMeta } from '../client.ts';
|
|
1
|
+
import { type ComparisonMethod, type SnapshotMeta } from '../client.ts';
|
|
2
2
|
import type { SetupVisSuiteCommand } from '../server/commands/setup_vis_suite.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Visual test configuration on the client side.
|
|
5
5
|
*/
|
|
6
|
-
export type VisClientConfigurator<
|
|
6
|
+
export type VisClientConfigurator<SM extends SnapshotMeta<ComparisonMethod>> = {
|
|
7
7
|
presets: {
|
|
8
8
|
/**
|
|
9
9
|
* Enable visual testing.
|
|
@@ -39,15 +39,15 @@ export type VisClientConfigurator<M extends SnapshotMeta<any>> = {
|
|
|
39
39
|
* })
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
theme(themes: Record<string, (options: M) => Promise<boolean> | Promise<void> | boolean | void>): void;
|
|
42
|
+
theme<M>(themes: Record<string, (options: M & SM) => Promise<boolean> | Promise<void> | boolean | void>): void;
|
|
43
43
|
};
|
|
44
44
|
beforeAll: {
|
|
45
45
|
setup(): Promise<void>;
|
|
46
46
|
};
|
|
47
47
|
afterEach: {
|
|
48
48
|
matchImageSnapshot(): Promise<void>;
|
|
49
|
-
matchPerTheme(themes: Record<string, (options: M) => Promise<boolean> | Promise<void> | boolean | void>): () => Promise<void>;
|
|
49
|
+
matchPerTheme<M>(themes: Record<string, (options: M & SM) => Promise<boolean> | Promise<void> | boolean | void>): () => Promise<void>;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
export declare function createVis<
|
|
52
|
+
export declare function createVis<SM extends SnapshotMeta<ComparisonMethod>>(commands: SetupVisSuiteCommand): VisClientConfigurator<SM>;
|
|
53
53
|
//# sourceMappingURL=create_vis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_vis.d.ts","sourceRoot":"","sources":["../../src/setup/create_vis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"create_vis.d.ts","sourceRoot":"","sources":["../../src/setup/create_vis.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAY,MAAM,cAAc,CAAA;AAIjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAEjF;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,EAAE,SAAS,YAAY,CAAC,gBAAgB,CAAC,IAAI;IAC9E,OAAO,EAAE;QACR;;;;;WAKG;QACH,MAAM,IAAI,IAAI,CAAA;QACd;;;;WAIG;QACH,MAAM,IAAI,IAAI,CAAA;QACd;;;;WAIG;QACH,IAAI,IAAI,IAAI,CAAA;QACZ;;;;;;;;;;;;;;WAcG;QACH,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;KAC9G,CAAA;IACD,SAAS,EAAE;QACV,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KACtB,CAAA;IACD,SAAS,EAAE;QACV,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;QACnC,aAAa,CAAC,CAAC,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC,GAC5F,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KACtB,CAAA;CACD,CAAA;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,YAAY,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,oBAAoB,6BAoFlG"}
|