vitest-plugin-vis 2.4.3 → 3.0.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/esm/client/actions/has_image_snapshot_action.d.ts +4 -0
- package/esm/client/actions/has_image_snapshot_action.d.ts.map +1 -0
- package/esm/client/actions/has_image_snapshot_action.js +6 -0
- package/esm/client/actions/load_image_snapshot_results_action.d.ts +3 -0
- package/esm/client/actions/load_image_snapshot_results_action.d.ts.map +1 -0
- package/esm/client/actions/load_image_snapshot_results_action.js +3 -0
- package/esm/client/actions/match_image_snapshot_action.d.ts +6 -0
- package/esm/client/actions/match_image_snapshot_action.d.ts.map +1 -0
- package/esm/client/actions/match_image_snapshot_action.js +20 -0
- package/esm/client/actions/match_page_image_snapshot_action.d.ts +6 -0
- package/esm/client/actions/match_page_image_snapshot_action.d.ts.map +1 -0
- package/esm/client/actions/match_page_image_snapshot_action.js +9 -0
- package/esm/client/auto_snapshot_options.d.ts +29 -0
- package/esm/client/auto_snapshot_options.d.ts.map +1 -0
- package/esm/client/auto_snapshot_options.js +49 -0
- package/esm/client/compare_image_snapshot.d.ts +6 -0
- package/esm/client/compare_image_snapshot.d.ts.map +1 -0
- package/esm/client/compare_image_snapshot.js +52 -0
- package/esm/client/{image_snapshot_matcher.logic.d.ts → compare_image_snapshot.logic.d.ts} +1 -1
- package/esm/client/compare_image_snapshot.logic.d.ts.map +1 -0
- package/esm/client/expect/to_match_image_snapshot.d.ts.map +1 -1
- package/esm/client/expect/to_match_image_snapshot.js +4 -3
- package/esm/client/image_resizer.d.ts.map +1 -1
- package/esm/client/image_snapshot_options.d.ts +2 -0
- package/esm/client/image_snapshot_options.d.ts.map +1 -0
- package/esm/client/image_snapshot_options.js +6 -0
- package/esm/client/page/augment.d.ts +2 -1
- package/esm/client/page/augment.d.ts.map +1 -1
- package/esm/client/page/extend.js +2 -1
- package/esm/client/page/has_image_snapshot.d.ts +6 -6
- package/esm/client/page/has_image_snapshot.d.ts.map +1 -1
- package/esm/client/page/has_image_snapshot.js +2 -11
- package/esm/client/page/to_match_image_snapshot.d.ts +8 -0
- package/esm/client/page/to_match_image_snapshot.d.ts.map +1 -0
- package/esm/client/page/to_match_image_snapshot.js +15 -0
- package/esm/client/setup/create_vis.d.ts +96 -0
- package/esm/client/setup/create_vis.d.ts.map +1 -0
- package/esm/{setup → client/setup}/create_vis.js +43 -31
- package/esm/client/setup/vis.ctx.d.ts +12 -0
- package/esm/client/setup/vis.ctx.d.ts.map +1 -0
- package/esm/client/setup/vis.ctx.js +32 -0
- package/esm/client/setup/vis.d.ts +5 -0
- package/esm/client/setup/vis.d.ts.map +1 -0
- package/esm/client/should_take_snapshot.d.ts +2 -9
- package/esm/client/should_take_snapshot.d.ts.map +1 -1
- package/esm/client/should_take_snapshot.js +1 -11
- package/esm/client/snapshot_meta.d.ts +6 -0
- package/esm/client/snapshot_meta.d.ts.map +1 -0
- package/esm/client/task_id.d.ts +0 -3
- package/esm/client/task_id.d.ts.map +1 -1
- package/esm/client/task_id.js +0 -3
- package/esm/client/vitest_suite_proxy.d.ts +2 -9
- package/esm/client/vitest_suite_proxy.d.ts.map +1 -1
- package/esm/client-api.d.ts +11 -0
- package/esm/client-api.d.ts.map +1 -0
- package/esm/client-api.js +8 -0
- package/esm/commands.d.ts +0 -1
- package/esm/commands.d.ts.map +1 -1
- package/esm/commands.js +0 -1
- package/esm/config/types.d.ts +22 -22
- package/esm/config/types.d.ts.map +1 -1
- package/esm/config/vis.d.ts +4 -3
- package/esm/config/vis.d.ts.map +1 -1
- package/esm/config/vis.js +3 -4
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/presets/auto.d.ts +1 -2
- package/esm/presets/auto.d.ts.map +1 -1
- package/esm/presets/auto.js +8 -4
- package/esm/presets/enable.d.ts +1 -2
- package/esm/presets/enable.d.ts.map +1 -1
- package/esm/presets/enable.js +4 -4
- package/esm/presets/manual.d.ts +1 -2
- package/esm/presets/manual.d.ts.map +1 -1
- package/esm/presets/manual.js +3 -4
- package/esm/server/browser_provider/playwright.d.ts.map +1 -1
- package/esm/server/browser_provider/playwright.js +9 -3
- package/esm/server/browser_provider/types.d.ts +5 -1
- package/esm/server/browser_provider/types.d.ts.map +1 -1
- package/esm/server/browser_provider/webdriverio.d.ts.map +1 -1
- package/esm/server/browser_provider/webdriverio.js +7 -4
- package/esm/server/commands/augment.d.ts +11 -0
- package/esm/server/commands/augment.d.ts.map +1 -0
- package/esm/server/commands/augment.js +1 -0
- package/esm/server/commands/commands.d.ts +9 -0
- package/esm/server/commands/commands.d.ts.map +1 -0
- package/esm/server/commands/commands.js +14 -0
- package/esm/server/commands/has_image_snapshot.d.ts +2 -6
- package/esm/server/commands/has_image_snapshot.d.ts.map +1 -1
- package/esm/server/commands/has_image_snapshot.js +3 -3
- package/esm/server/commands/image_snapshot_next_index.d.ts +1 -1
- package/esm/server/commands/image_snapshot_next_index.d.ts.map +1 -1
- package/esm/server/commands/image_snapshot_next_index.js +2 -2
- package/esm/server/commands/load_image_snapshot_results.d.ts +21 -0
- package/esm/server/commands/load_image_snapshot_results.d.ts.map +1 -0
- package/esm/server/commands/load_image_snapshot_results.js +6 -0
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts +8 -10
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +1 -1
- package/esm/server/commands/prepare_image_snapshot_comparison.js +11 -9
- package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts +35 -0
- package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts.map +1 -0
- package/esm/server/commands/prepare_page_image_snapshot_comparison.js +27 -0
- package/esm/server/commands/setup_vis_suite.d.ts +3 -3
- package/esm/server/commands/setup_vis_suite.d.ts.map +1 -1
- package/esm/server/commands/setup_vis_suite.js +2 -3
- package/esm/server/commands/types.d.ts +3 -0
- package/esm/server/commands/types.d.ts.map +1 -0
- package/esm/server/commands/types.js +1 -0
- package/esm/server/externals/file.d.ts +10 -0
- package/esm/server/externals/file.d.ts.map +1 -0
- package/esm/server/{file.js → externals/file.js} +12 -4
- package/esm/server/{commands/browser_command_context.d.ts → project.d.ts} +8 -3
- package/esm/server/project.d.ts.map +1 -0
- package/esm/server/{commands/browser_command_context.js → project.js} +2 -2
- package/esm/server/snapshot.d.ts +4 -5
- package/esm/server/snapshot.d.ts.map +1 -1
- package/esm/server/snapshot.js +15 -13
- package/esm/server/snapshot_path.d.ts +3 -3
- package/esm/server/snapshot_path.d.ts.map +1 -1
- package/esm/server/snapshot_path.js +12 -11
- package/esm/server/snapshot_writer.d.ts +13 -0
- package/esm/server/snapshot_writer.d.ts.map +1 -0
- package/esm/server/snapshot_writer.js +15 -0
- package/esm/server/suite.d.ts +53 -0
- package/esm/server/suite.d.ts.map +1 -0
- package/esm/server/suite.js +73 -0
- package/esm/server/vis_options.d.ts +18 -0
- package/esm/server/vis_options.d.ts.map +1 -0
- package/esm/server/vis_options.js +14 -0
- package/esm/server/vis_server_context.d.ts +50 -0
- package/esm/server/vis_server_context.d.ts.map +1 -0
- package/esm/server/{vis_context.ctx.d.ts → vis_server_context.deps.d.ts} +2 -2
- package/esm/server/vis_server_context.deps.d.ts.map +1 -0
- package/esm/server/{vis_context.ctx.js → vis_server_context.deps.js} +1 -1
- package/esm/server/vis_server_context.js +2 -0
- package/esm/server/{vis_context.logic.d.ts → vis_server_context.logic.d.ts} +12 -32
- package/esm/server/vis_server_context.logic.d.ts.map +1 -0
- package/esm/server/vis_server_context.logic.js +79 -0
- package/esm/server/{vis_context.types.d.ts → vis_server_context.types.d.ts} +6 -6
- package/esm/server/vis_server_context.types.d.ts.map +1 -0
- package/esm/server/vis_server_context.types.js +1 -0
- package/esm/server-utils.d.ts +3 -0
- package/esm/server-utils.d.ts.map +1 -0
- package/esm/server-utils.js +2 -0
- package/esm/setup.d.ts +2 -2
- package/esm/setup.d.ts.map +1 -1
- package/esm/setup.js +2 -2
- package/esm/shared/asserts.d.ts +2 -0
- package/esm/shared/asserts.d.ts.map +1 -0
- package/esm/shared/asserts.js +5 -0
- package/esm/shared/types.d.ts +22 -21
- package/esm/shared/types.d.ts.map +1 -1
- package/esm/testing/stubBrowserCommandContext.d.ts +1 -1
- package/esm/testing/stubBrowserCommandContext.d.ts.map +1 -1
- package/esm/testing/stubBrowserCommandContext.js +3 -13
- package/esm/testing/stubSuite.d.ts +10 -0
- package/esm/testing/stubSuite.d.ts.map +1 -0
- package/esm/testing/stubSuite.js +27 -0
- package/esm/testing/stubUserConfig.d.ts +7 -0
- package/esm/testing/stubUserConfig.d.ts.map +1 -0
- package/esm/testing/stubUserConfig.js +4 -0
- package/package.json +29 -28
- package/readme.md +409 -110
- package/src/client/actions/has_image_snapshot_action.ts +14 -0
- package/src/client/actions/load_image_snapshot_results_action.ts +5 -0
- package/src/client/actions/match_image_snapshot_action.ts +32 -0
- package/src/client/actions/match_page_image_snapshot_action.ts +20 -0
- package/src/client/auto_snapshot_options.ts +71 -0
- package/src/client/compare_image_snapshot.ts +84 -0
- package/src/client/expect/to_match_image_snapshot.ts +4 -3
- package/src/client/image_snapshot_options.ts +6 -0
- package/src/client/page/augment.ts +2 -1
- package/src/client/page/extend.ts +2 -1
- package/src/client/page/has_image_snapshot.ts +8 -21
- package/src/client/page/to_match_image_snapshot.ts +27 -0
- package/src/client/setup/create_vis.ts +227 -0
- package/src/client/setup/vis.ctx.ts +33 -0
- package/src/client/should_take_snapshot.ts +3 -13
- package/src/client/snapshot_meta.ts +7 -0
- package/src/client/task_id.ts +0 -3
- package/src/client/vitest_suite_proxy.ts +2 -5
- package/src/client-api.ts +11 -0
- package/src/commands.ts +0 -1
- package/src/config/types.ts +32 -27
- package/src/config/vis.ts +3 -5
- package/src/index.ts +1 -1
- package/src/presets/auto.ts +8 -4
- package/src/presets/enable.ts +4 -4
- package/src/presets/manual.ts +3 -4
- package/src/server/browser_provider/playwright.ts +9 -3
- package/src/server/browser_provider/types.ts +12 -1
- package/src/server/browser_provider/webdriverio.ts +7 -4
- package/src/server/commands/augment.ts +16 -0
- package/src/server/commands/commands.ts +15 -0
- package/src/server/commands/has_image_snapshot.ts +8 -6
- package/src/server/commands/image_snapshot_next_index.ts +5 -3
- package/src/server/commands/load_image_snapshot_results.ts +32 -0
- package/src/server/commands/prepare_image_snapshot_comparison.ts +20 -14
- package/src/server/commands/prepare_page_image_snapshot_comparison.ts +75 -0
- package/src/server/commands/setup_vis_suite.ts +17 -7
- package/src/server/commands/types.ts +9 -0
- package/src/server/externals/file.ts +21 -0
- package/src/server/{commands/browser_command_context.ts → project.ts} +2 -4
- package/src/server/snapshot.ts +23 -14
- package/src/server/snapshot_path.ts +15 -13
- package/src/server/snapshot_writer.ts +22 -0
- package/src/server/suite.ts +96 -0
- package/src/server/vis_options.ts +27 -0
- package/src/server/{vis_context.ctx.ts → vis_server_context.deps.ts} +1 -1
- package/src/server/vis_server_context.logic.ts +112 -0
- package/src/server/vis_server_context.ts +3 -0
- package/src/server/{vis_context.types.ts → vis_server_context.types.ts} +5 -5
- package/src/server-utils.ts +2 -0
- package/src/setup.ts +2 -2
- package/src/shared/asserts.ts +5 -0
- package/src/shared/types.ts +25 -23
- package/src/testing/stubBrowserCommandContext.ts +4 -14
- package/src/testing/stubSuite.ts +38 -0
- package/src/testing/stubUserConfig.ts +6 -0
- package/esm/client/image_snapshot_matcher.d.ts +0 -11
- package/esm/client/image_snapshot_matcher.d.ts.map +0 -1
- package/esm/client/image_snapshot_matcher.js +0 -80
- package/esm/client/image_snapshot_matcher.logic.d.ts.map +0 -1
- package/esm/client/snapshot_options.d.ts +0 -33
- package/esm/client/snapshot_options.d.ts.map +0 -1
- package/esm/client/snapshot_options.js +0 -37
- package/esm/client.d.ts +0 -8
- package/esm/client.d.ts.map +0 -1
- package/esm/client.js +0 -5
- package/esm/server/commands/browser_command_context.d.ts.map +0 -1
- package/esm/server/commands/extend.d.ts +0 -17
- package/esm/server/commands/extend.d.ts.map +0 -1
- package/esm/server/commands/extend.js +0 -12
- package/esm/server/commands/match_image_snapshot.d.ts +0 -18
- package/esm/server/commands/match_image_snapshot.d.ts.map +0 -1
- package/esm/server/commands/match_image_snapshot.js +0 -81
- package/esm/server/file.d.ts +0 -7
- package/esm/server/file.d.ts.map +0 -1
- package/esm/server/vis_context.ctx.d.ts.map +0 -1
- package/esm/server/vis_context.d.ts +0 -56
- package/esm/server/vis_context.d.ts.map +0 -1
- package/esm/server/vis_context.js +0 -2
- package/esm/server/vis_context.logic.d.ts.map +0 -1
- package/esm/server/vis_context.logic.js +0 -135
- package/esm/server/vis_context.types.d.ts.map +0 -1
- package/esm/setup/create_vis.d.ts +0 -53
- package/esm/setup/create_vis.d.ts.map +0 -1
- package/esm/setup/vis.d.ts +0 -5
- package/esm/setup/vis.d.ts.map +0 -1
- package/src/client/image_snapshot_matcher.ts +0 -121
- package/src/client/snapshot_options.ts +0 -82
- package/src/client.ts +0 -7
- package/src/server/commands/extend.ts +0 -25
- package/src/server/commands/match_image_snapshot.ts +0 -128
- package/src/server/file.ts +0 -13
- package/src/server/vis_context.logic.ts +0 -198
- package/src/server/vis_context.ts +0 -3
- package/src/setup/create_vis.ts +0 -154
- /package/esm/client/{image_snapshot_matcher.logic.js → compare_image_snapshot.logic.js} +0 -0
- /package/esm/{setup → client/setup}/vis.js +0 -0
- /package/esm/{server/vis_context.types.js → client/snapshot_meta.js} +0 -0
- /package/src/client/{image_snapshot_matcher.logic.ts → compare_image_snapshot.logic.ts} +0 -0
- /package/src/{setup → client/setup}/vis.ts +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { ComparisonMethod, SnapshotMeta } from '../shared/types.ts';
|
|
2
|
-
type Suite = {
|
|
3
|
-
meta: Record<string, any>;
|
|
4
|
-
suite?: Suite | undefined;
|
|
5
|
-
};
|
|
6
|
-
export type MetaTask = {
|
|
7
|
-
file?: {
|
|
8
|
-
meta: Record<string, any>;
|
|
9
|
-
} | undefined;
|
|
10
|
-
suite?: Suite | undefined;
|
|
11
|
-
meta: Record<string, any>;
|
|
12
|
-
} | undefined;
|
|
13
|
-
export declare function enableAuto(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Set the snapshot options for auto snapshot.
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* beforeAll((suite) => setAutoSnapshotOptions(suite, ...))
|
|
19
|
-
* beforeEach(({ task }) => setAutoSnapshotOptions(task, ...))
|
|
20
|
-
*
|
|
21
|
-
* it('...', ({ task }) => {
|
|
22
|
-
* setAutoSnapshotOptions(task, ...)
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @param task Optional. Suite or task to set the options.
|
|
27
|
-
* If not provided, it will set the options for the current test.
|
|
28
|
-
*/
|
|
29
|
-
export declare function setAutoSnapshotOptions<M extends ComparisonMethod>(task: MetaTask, meta: SnapshotMeta<M> | boolean): void;
|
|
30
|
-
export declare function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: SnapshotMeta<M> | boolean): void;
|
|
31
|
-
export declare function extractAutoSnapshotOptions<M extends SnapshotMeta<any> = SnapshotMeta<any>>(task: MetaTask): M | undefined;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=snapshot_options.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { NAME } from "../shared/constants.js";
|
|
2
|
-
import { ctx } from "./ctx.js";
|
|
3
|
-
export function enableAuto() {
|
|
4
|
-
ctx.autoEnabled = true;
|
|
5
|
-
}
|
|
6
|
-
export function setAutoSnapshotOptions(...args) {
|
|
7
|
-
const [task, meta] = parseArgs(args);
|
|
8
|
-
if (task)
|
|
9
|
-
task.meta[NAME] = {
|
|
10
|
-
...task.meta[NAME],
|
|
11
|
-
...meta,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function parseArgs(args) {
|
|
15
|
-
return args.length === 1
|
|
16
|
-
? [ctx.getCurrentTest() ?? ctx.getCurrentSuite()?.tasks?.[0]?.file, parseMeta(args[0])]
|
|
17
|
-
: [args[0], parseMeta(args[1])];
|
|
18
|
-
}
|
|
19
|
-
function parseMeta(meta) {
|
|
20
|
-
return typeof meta === 'boolean' ? { enable: meta } : { enable: true, ...meta };
|
|
21
|
-
}
|
|
22
|
-
export function extractAutoSnapshotOptions(task) {
|
|
23
|
-
if (!task)
|
|
24
|
-
return;
|
|
25
|
-
const list = [];
|
|
26
|
-
let current = task;
|
|
27
|
-
while (current?.suite) {
|
|
28
|
-
list.unshift(current.suite.meta);
|
|
29
|
-
current = current.suite;
|
|
30
|
-
}
|
|
31
|
-
list.unshift(task.file?.meta);
|
|
32
|
-
list.push(task.meta);
|
|
33
|
-
return list.reduce((acc, cur) => {
|
|
34
|
-
const meta = cur?.[NAME];
|
|
35
|
-
return meta ? Object.assign({}, acc, meta) : acc;
|
|
36
|
-
}, { enable: ctx.autoEnabled });
|
|
37
|
-
}
|
package/esm/client.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './client/expect/expectation_result.ts';
|
|
2
|
-
export type * from './client/expect/to_match_image_snapshot.types.ts';
|
|
3
|
-
export * from './client/image_snapshot_matcher.ts';
|
|
4
|
-
export * from './client/should_take_snapshot.ts';
|
|
5
|
-
export { setAutoSnapshotOptions, type MetaTask } from './client/snapshot_options.ts';
|
|
6
|
-
export * from './client/task_id.ts';
|
|
7
|
-
export type * from './shared/types.ts';
|
|
8
|
-
//# sourceMappingURL=client.d.ts.map
|
package/esm/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/client.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * from "./client/expect/expectation_result.js";
|
|
2
|
-
export * from "./client/image_snapshot_matcher.js";
|
|
3
|
-
export * from "./client/should_take_snapshot.js";
|
|
4
|
-
export { setAutoSnapshotOptions } from "./client/snapshot_options.js";
|
|
5
|
-
export * from "./client/task_id.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"browser_command_context.d.ts","sourceRoot":"","sources":["../../../src/server/commands/browser_command_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,wBAAgB,cAAc,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE;QAAE,IAAI,EAAE;YAAE,MAAM,EAAE;gBAAE,IAAI,CAAC,EAAE;oBAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;iBAAE,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,sBAElH;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,qBAAqB,wCAE3E"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type HasImageSnapshotCommand } from './has_image_snapshot.ts';
|
|
2
|
-
import { type ImageSnapshotNextIndexCommand } from './image_snapshot_next_index.ts';
|
|
3
|
-
import { type MatchImageSnapshotCommand } from './match_image_snapshot.ts';
|
|
4
|
-
import { type PrepareImageSnapshotComparisonCommand } from './prepare_image_snapshot_comparison.ts';
|
|
5
|
-
import { type SetupVisSuiteCommand } from './setup_vis_suite.ts';
|
|
6
|
-
declare module '@vitest/browser/context' {
|
|
7
|
-
interface BrowserCommands extends SetupVisSuiteCommand, ImageSnapshotNextIndexCommand, HasImageSnapshotCommand, PrepareImageSnapshotComparisonCommand, MatchImageSnapshotCommand {
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export declare const commands: {
|
|
11
|
-
setupVisSuite: import("vitest/node").BrowserCommand<[]>;
|
|
12
|
-
imageSnapshotNextIndex: import("vitest/node").BrowserCommand<[taskId: string]>;
|
|
13
|
-
hasImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string | undefined, isAutoSnapshot: boolean]>;
|
|
14
|
-
matchImageSnapshot: import("vitest/node").BrowserCommand<[taskId: string, subject: string, isAutoSnapshot: boolean, options?: import("./match_image_snapshot.ts").MatchImageSnapshotOptions | undefined]>;
|
|
15
|
-
prepareImageSnapshotComparison: import("vitest/node").BrowserCommand<[taskId: string, snapshotId: string, isAutoSnapshot: boolean, options?: import("./match_image_snapshot.ts").MatchImageSnapshotOptions | undefined]>;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../src/server/commands/extend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,uBAAuB,EAAoB,MAAM,yBAAyB,CAAA;AACxF,OAAO,EAAE,KAAK,6BAA6B,EAA0B,MAAM,gCAAgC,CAAA;AAC3G,OAAO,EAAE,KAAK,yBAAyB,EAAsB,MAAM,2BAA2B,CAAA;AAC9F,OAAO,EACN,KAAK,qCAAqC,EAE1C,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,KAAK,oBAAoB,EAAiB,MAAM,sBAAsB,CAAA;AAE/E,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,eACT,SAAQ,oBAAoB,EAC3B,6BAA6B,EAC7B,uBAAuB,EACvB,qCAAqC,EACrC,yBAAyB;KAAG;CAC9B;AAED,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { hasImageSnapshot } from "./has_image_snapshot.js";
|
|
2
|
-
import { imageSnapshotNextIndex } from "./image_snapshot_next_index.js";
|
|
3
|
-
import { matchImageSnapshot } from "./match_image_snapshot.js";
|
|
4
|
-
import { prepareImageSnapshotComparison, } from "./prepare_image_snapshot_comparison.js";
|
|
5
|
-
import { setupVisSuite } from "./setup_vis_suite.js";
|
|
6
|
-
export const commands = {
|
|
7
|
-
setupVisSuite,
|
|
8
|
-
imageSnapshotNextIndex,
|
|
9
|
-
hasImageSnapshot,
|
|
10
|
-
matchImageSnapshot,
|
|
11
|
-
prepareImageSnapshotComparison,
|
|
12
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BrowserCommand } from 'vitest/node';
|
|
2
|
-
import type { ImageSnapshotCompareOptions, ImageSnapshotIdOptions, ImageSnapshotTimeoutOptions } from '../../shared/types.ts';
|
|
3
|
-
export interface MatchImageSnapshotCommand {
|
|
4
|
-
matchImageSnapshot: (taskId: string | undefined, subject: string, isAutoSnapshot: boolean, options?: MatchImageSnapshotOptions | undefined) => Promise<void>;
|
|
5
|
-
}
|
|
6
|
-
export type MatchImageSnapshotOptions = ImageSnapshotTimeoutOptions & ImageSnapshotIdOptions & ImageSnapshotCompareOptions<any> & {
|
|
7
|
-
/**
|
|
8
|
-
* The snapshot file id calculated on the client side.
|
|
9
|
-
*/
|
|
10
|
-
snapshotFileId?: string | undefined;
|
|
11
|
-
};
|
|
12
|
-
export declare const matchImageSnapshot: BrowserCommand<[
|
|
13
|
-
taskId: string,
|
|
14
|
-
subject: string,
|
|
15
|
-
isAutoSnapshot: boolean,
|
|
16
|
-
options?: MatchImageSnapshotOptions | undefined
|
|
17
|
-
]>;
|
|
18
|
-
//# sourceMappingURL=match_image_snapshot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import dedent from 'dedent';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
3
|
-
import { PNG } from 'pngjs';
|
|
4
|
-
import { isBase64String } from "../../shared/base64.js";
|
|
5
|
-
import { compareImage } from "../../shared/compare_image.js";
|
|
6
|
-
import { getMaxSize } from "../../shared/get_max_size.js";
|
|
7
|
-
import { isSameSize } from "../../shared/is_same_size.js";
|
|
8
|
-
import { file } from "../file.js";
|
|
9
|
-
import { takeSnapshot, takeSnapshotByBrowser, writeSnapshot, writeSnapshotBuffer } from "../snapshot.js";
|
|
10
|
-
import { visContext } from "../vis_context.js";
|
|
11
|
-
import { assertTestPathDefined } from "./_assertions.js";
|
|
12
|
-
export const matchImageSnapshot = async (context, taskId, subject, isAutoSnapshot, options) => {
|
|
13
|
-
assertTestPathDefined(context, 'matchImageSnapshot');
|
|
14
|
-
// vitest:browser passes in `null` when not defined
|
|
15
|
-
if (!options)
|
|
16
|
-
options = {};
|
|
17
|
-
options.timeout = options.timeout ?? 30000;
|
|
18
|
-
const info = await visContext.getSnapshotInfo(context, taskId, isAutoSnapshot, options);
|
|
19
|
-
const baselineBuffer = await file.tryReadFile(info.baselinePath);
|
|
20
|
-
if (!baselineBuffer) {
|
|
21
|
-
if (isBase64String(subject)) {
|
|
22
|
-
await writeSnapshot(info.baselinePath, subject);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
await takeSnapshotByBrowser(context, info.baselinePath, subject, options);
|
|
26
|
-
}
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const resultBuffer = await takeSnapshot(context, info.resultPath, subject, options);
|
|
30
|
-
const baselineImage = PNG.sync.read(baselineBuffer, { skipRescale: true, checkCRC: false });
|
|
31
|
-
const resultImage = PNG.sync.read(resultBuffer, { skipRescale: true, checkCRC: false });
|
|
32
|
-
const [baselineAlignedImage, resultAlignedImage] = alignImageSizes(baselineImage, resultImage);
|
|
33
|
-
const { width, height } = baselineAlignedImage;
|
|
34
|
-
const diffImage = new PNG({ width, height });
|
|
35
|
-
const { pass, diffAmount } = compareImage(baselineAlignedImage.data, resultAlignedImage.data, diffImage.data, width, height, options);
|
|
36
|
-
if (pass) {
|
|
37
|
-
if (sizeNotChanged(baselineImage, baselineAlignedImage) && sizeNotChanged(resultImage, resultAlignedImage)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
throw new Error(dedent `Snapshot \`${taskId}\` mismatched
|
|
41
|
-
|
|
42
|
-
The image size changed form ${baselineImage.width}x${baselineImage.height} to ${resultImage.width}x${resultImage.height}
|
|
43
|
-
|
|
44
|
-
Expected: ${resolve(context.project.config.root, info.baselinePath)}
|
|
45
|
-
Actual: ${resolve(context.project.config.root, info.resultPath)}`);
|
|
46
|
-
}
|
|
47
|
-
if (context.project.config.snapshotOptions.updateSnapshot === 'all') {
|
|
48
|
-
await writeSnapshotBuffer(info.baselinePath, resultImage.data);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
await writeSnapshotBuffer(info.diffPath, diffImage.data);
|
|
52
|
-
throw new Error(dedent `Snapshot \`${taskId}\` mismatched
|
|
53
|
-
|
|
54
|
-
${options?.failureThreshold
|
|
55
|
-
? options?.failureThresholdType === 'percent'
|
|
56
|
-
? `Expected image to match within ${options.failureThreshold}% but was differ by ${diffAmount}%.`
|
|
57
|
-
: `Expected image to match within ${options.failureThreshold} pixels but was differ by ${diffAmount} pixels.`
|
|
58
|
-
: `Expected image to match but was differ by ${options?.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}.`}
|
|
59
|
-
|
|
60
|
-
Options: ${JSON.stringify(options)}
|
|
61
|
-
|
|
62
|
-
Expected: ${resolve(context.project.config.root, info.baselinePath)}
|
|
63
|
-
Actual: ${resolve(context.project.config.root, info.resultPath)}
|
|
64
|
-
Difference: ${resolve(context.project.config.root, info.diffPath)}`);
|
|
65
|
-
};
|
|
66
|
-
function alignImageSizes(baseline, result) {
|
|
67
|
-
if (isSameSize(baseline, result))
|
|
68
|
-
return [baseline, result];
|
|
69
|
-
const size = getMaxSize(baseline, result);
|
|
70
|
-
return [resizeImage(baseline, size), resizeImage(result, size)];
|
|
71
|
-
}
|
|
72
|
-
function resizeImage(image, size) {
|
|
73
|
-
if (isSameSize(image, size))
|
|
74
|
-
return image;
|
|
75
|
-
const resized = new PNG(size);
|
|
76
|
-
PNG.bitblt(image, resized, 0, 0, image.width, image.height);
|
|
77
|
-
return resized;
|
|
78
|
-
}
|
|
79
|
-
function sizeNotChanged(baselineImage, baselineAlignedImage) {
|
|
80
|
-
return baselineImage === baselineAlignedImage;
|
|
81
|
-
}
|
package/esm/server/file.d.ts
DELETED
package/esm/server/file.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/server/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5D,eAAO,MAAM,IAAI;0BACY,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;;wBAI5C,MAAM;CAK1B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.ctx.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ctx.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,GAAG;;6CAOksD,CAAC;2CAAkF,CAAC;iDAA8E,CAAC;8CAA2E,CAAC;+CAA0F,CAAC;;iDAAqF,CAAC;8CAA2E,CAAC;+CAA0F,CAAC;;iDAAqF,CAAC;6CAA0E,CAAC;+CAA0F,CAAC;;gDAAoF,CAAC;+CAA4E,CAAC;+CAA0F,CAAC;;kDAAsF,CAAC;kDAA+E,CAAC;+CAA0F,CAAC;;qDAAyF,CAAC;;;CAF7mG,CAAA"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
export declare const visContext: {
|
|
2
|
-
setOptions<M extends "pixel" | "ssim">(projectName: string | undefined, options?: import("../config.ts").VisOptions<M>): void;
|
|
3
|
-
__test__getOptions(projectName: string): import("../config.ts").VisOptions<any> | undefined;
|
|
4
|
-
__test__reset(): void;
|
|
5
|
-
__test__getState(context: import("./vis_context.types.ts").PartialBrowserCommandContext): Promise<import("./vis_context.types.ts").VisProjectState>;
|
|
6
|
-
setupSuite(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext): Promise<import("type-plus").Pick._<import("./vis_context.types.ts").VisProjectState, "subjectDataTestId">>;
|
|
7
|
-
getSnapshotInfo(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, name: string, isAutoSnapshot: boolean, options?: {
|
|
8
|
-
snapshotFileId?: string | undefined;
|
|
9
|
-
}): Promise<{
|
|
10
|
-
baselinePath: string;
|
|
11
|
-
resultPath: string;
|
|
12
|
-
diffPath: string;
|
|
13
|
-
timeout?: number | undefined | undefined;
|
|
14
|
-
comparisonMethod: any;
|
|
15
|
-
diffOptions?: Partial<import("ssim.js").Options> | undefined;
|
|
16
|
-
failureThresholdType?: "pixel" | "percent" | undefined | undefined;
|
|
17
|
-
failureThreshold?: number | undefined | undefined;
|
|
18
|
-
} | {
|
|
19
|
-
baselinePath: string;
|
|
20
|
-
resultPath: string;
|
|
21
|
-
diffPath: string;
|
|
22
|
-
timeout?: number | undefined | undefined;
|
|
23
|
-
comparisonMethod?: any;
|
|
24
|
-
diffOptions?: {
|
|
25
|
-
threshold?: number | undefined;
|
|
26
|
-
includeAA?: boolean | undefined;
|
|
27
|
-
alpha?: number | undefined;
|
|
28
|
-
aaColor?: [number, number, number] | undefined;
|
|
29
|
-
diffColor?: [number, number, number] | undefined;
|
|
30
|
-
diffColorAlt?: [number, number, number] | undefined;
|
|
31
|
-
diffMask?: boolean | undefined;
|
|
32
|
-
} | undefined;
|
|
33
|
-
failureThresholdType?: "pixel" | "percent" | undefined | undefined;
|
|
34
|
-
failureThreshold?: number | undefined | undefined;
|
|
35
|
-
}>;
|
|
36
|
-
getTaskCount(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, taskId: string): Promise<number>;
|
|
37
|
-
hasImageSnapshot(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, taskId: string, snapshotFileId: string | undefined, isAutoSnapshot: boolean): Promise<boolean>;
|
|
38
|
-
getSnapshotFilename(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, info: {
|
|
39
|
-
taskId: string;
|
|
40
|
-
task: {
|
|
41
|
-
count: number;
|
|
42
|
-
};
|
|
43
|
-
}, snapshotFileId: string | undefined, isAutoSnapshot: boolean): string;
|
|
44
|
-
getSuiteInfo(browserContext: import("./vis_context.types.ts").PartialBrowserCommandContext, taskId: string): Promise<{
|
|
45
|
-
projectRoot: string;
|
|
46
|
-
suiteId: string;
|
|
47
|
-
taskId: string;
|
|
48
|
-
baselineDir: string;
|
|
49
|
-
resultDir: string;
|
|
50
|
-
diffDir: string;
|
|
51
|
-
task: {
|
|
52
|
-
count: number;
|
|
53
|
-
};
|
|
54
|
-
}>;
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=vis_context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;;;;;;;sBAC86D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD15D,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
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;AAMpD,OAAO,KAAK,EAAE,4BAA4B,EAAE,eAAe,EAAY,MAAM,wBAAwB,CAAA;AAErG,wBAAgB,gBAAgB;eAKnB,CAAC,SAAS,OAAO,GAAG,MAAM,eAAe,MAAM,GAAG,SAAS,YAAW,UAAU,CAAC,CAAC,CAAC;oCAG9D,MAAM;;8BAOZ,4BAA4B;IAGtD;;;;OAIG;+BAC8B,4BAA4B;oCAiB5C,4BAA4B,QACtC,MAAM,kBACI,OAAO,YACb;QAAE,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;iCA+Bf,4BAA4B,UAAU,MAAM;qCAI9D,4BAA4B,UACpC,MAAM,kBACE,MAAM,GAAG,SAAS,kBAClB,OAAO;wCAaP,4BAA4B,QACtC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,kBACjC,MAAM,GAAG,SAAS,kBAClB,OAAO;iCAWW,4BAA4B,UAAU,MAAM;;;;;;;;;;;EAmBhF;AAyBD,wBAAgB,WAAW,CAC1B,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC;;;;;;;;EAYrD;AAED,wBAAgB,UAAU,CACzB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,0BAA0B,CAAC,UAGrD"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { join, relative, resolve } from 'pathe';
|
|
2
|
-
import { pick } from 'type-plus';
|
|
3
|
-
import { BASELINE_DIR, DIFF_DIR, RESULT_DIR } from "../shared/constants.js";
|
|
4
|
-
import { getProjectName } from "./commands/browser_command_context.js";
|
|
5
|
-
import { file } from "./file.js";
|
|
6
|
-
import { getSnapshotSubpath, resolveSnapshotRootDir } from "./snapshot_path.js";
|
|
7
|
-
import { ctx } from "./vis_context.ctx.js";
|
|
8
|
-
export function createVisContext() {
|
|
9
|
-
let visOptionsRecord = {};
|
|
10
|
-
let state = {};
|
|
11
|
-
const context = {
|
|
12
|
-
setOptions(projectName, options = {}) {
|
|
13
|
-
visOptionsRecord[projectName ?? '__default'] = options;
|
|
14
|
-
},
|
|
15
|
-
__test__getOptions(projectName) {
|
|
16
|
-
return visOptionsRecord[projectName];
|
|
17
|
-
},
|
|
18
|
-
__test__reset() {
|
|
19
|
-
visOptionsRecord = {};
|
|
20
|
-
state = {};
|
|
21
|
-
},
|
|
22
|
-
__test__getState(context) {
|
|
23
|
-
return state[getProjectId(context)];
|
|
24
|
-
},
|
|
25
|
-
/**
|
|
26
|
-
* Setup suite is called on each test file's beforeAll hook.
|
|
27
|
-
* Test files include vitest test files and storybook story files.
|
|
28
|
-
* It needs to make sure there is no race condition between the test files.
|
|
29
|
-
*/
|
|
30
|
-
async setupSuite(browserContext) {
|
|
31
|
-
const projectId = getProjectId(browserContext);
|
|
32
|
-
const visOptions = getVisOptions(visOptionsRecord, browserContext);
|
|
33
|
-
if (!state[projectId]) {
|
|
34
|
-
state[projectId] = setupState(browserContext, visOptions);
|
|
35
|
-
}
|
|
36
|
-
const projectState = await state[projectId];
|
|
37
|
-
const { suiteId, suite } = createSuite(projectState, browserContext.testPath, visOptions);
|
|
38
|
-
projectState.suites[suiteId] = suite;
|
|
39
|
-
await Promise.allSettled([ctx.rimraf(suite.diffDir), ctx.rimraf(suite.resultDir)]);
|
|
40
|
-
return pick(projectState, 'subjectDataTestId');
|
|
41
|
-
},
|
|
42
|
-
async getSnapshotInfo(browserContext, name, isAutoSnapshot, options) {
|
|
43
|
-
const suiteInfo = await context.getSuiteInfo(browserContext, name);
|
|
44
|
-
const snapshotFilename = context.getSnapshotFilename(browserContext, suiteInfo, options?.snapshotFileId, isAutoSnapshot);
|
|
45
|
-
const { baselineDir, resultDir, diffDir, task } = suiteInfo;
|
|
46
|
-
task.count = task.count + 1;
|
|
47
|
-
const baselinePath = join(baselineDir, snapshotFilename);
|
|
48
|
-
const resultPath = join(resultDir, snapshotFilename);
|
|
49
|
-
const diffPath = join(diffDir, snapshotFilename);
|
|
50
|
-
return {
|
|
51
|
-
...pick(getVisOptions(visOptionsRecord, browserContext), 'comparisonMethod', 'diffOptions', 'failureThreshold', 'failureThresholdType', 'timeout'),
|
|
52
|
-
baselinePath,
|
|
53
|
-
resultPath,
|
|
54
|
-
diffPath,
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
async getTaskCount(browserContext, taskId) {
|
|
58
|
-
return (await context.getSuiteInfo(browserContext, taskId)).task.count;
|
|
59
|
-
},
|
|
60
|
-
async hasImageSnapshot(browserContext, taskId, snapshotFileId, isAutoSnapshot) {
|
|
61
|
-
const info = await context.getSuiteInfo(browserContext, taskId);
|
|
62
|
-
return file.existFile(resolve(info.projectRoot, info.baselineDir, context.getSnapshotFilename(browserContext, info, snapshotFileId, isAutoSnapshot)));
|
|
63
|
-
},
|
|
64
|
-
getSnapshotFilename(browserContext, info, snapshotFileId, isAutoSnapshot) {
|
|
65
|
-
if (snapshotFileId)
|
|
66
|
-
return `${snapshotFileId}.png`;
|
|
67
|
-
const customizeSnapshotId = getVisOptions(visOptionsRecord, browserContext).customizeSnapshotId ?? (({ id, index }) => `${id}-${index}`);
|
|
68
|
-
return `${customizeSnapshotId({
|
|
69
|
-
id: info.taskId,
|
|
70
|
-
index: info.task.count,
|
|
71
|
-
isAutoSnapshot,
|
|
72
|
-
})}.png`;
|
|
73
|
-
},
|
|
74
|
-
async getSuiteInfo(browserContext, taskId) {
|
|
75
|
-
const projectId = getProjectId(browserContext);
|
|
76
|
-
const projectState = await state[projectId];
|
|
77
|
-
const visOptions = getVisOptions(visOptionsRecord, browserContext);
|
|
78
|
-
const suiteId = getSuiteId(projectState, browserContext.testPath, visOptions);
|
|
79
|
-
const suite = projectState.suites[suiteId];
|
|
80
|
-
const task = (suite.tasks[taskId] = suite.tasks[taskId] ?? { count: 1 });
|
|
81
|
-
return {
|
|
82
|
-
projectRoot: projectState.projectRoot,
|
|
83
|
-
suiteId,
|
|
84
|
-
taskId,
|
|
85
|
-
baselineDir: suite.baselineDir,
|
|
86
|
-
resultDir: suite.resultDir,
|
|
87
|
-
diffDir: suite.diffDir,
|
|
88
|
-
task,
|
|
89
|
-
};
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
return context;
|
|
93
|
-
}
|
|
94
|
-
async function setupState(browserContext, visOptions) {
|
|
95
|
-
const snapshotRootDir = resolveSnapshotRootDir(browserContext, visOptions);
|
|
96
|
-
const projectRoot = getProjectRoot(browserContext);
|
|
97
|
-
const state = {
|
|
98
|
-
projectRoot,
|
|
99
|
-
testTimeout: browserContext.project.config.testTimeout,
|
|
100
|
-
hookTimeout: browserContext.project.config.hookTimeout,
|
|
101
|
-
snapshotRootDir,
|
|
102
|
-
snapshotBaselineDir: join(snapshotRootDir, BASELINE_DIR),
|
|
103
|
-
snapshotResultDir: join(snapshotRootDir, RESULT_DIR),
|
|
104
|
-
snapshotDiffDir: join(snapshotRootDir, DIFF_DIR),
|
|
105
|
-
snapshotRootPath: join(projectRoot, snapshotRootDir),
|
|
106
|
-
subjectDataTestId: visOptions.subjectDataTestId,
|
|
107
|
-
suites: {},
|
|
108
|
-
};
|
|
109
|
-
await Promise.allSettled([ctx.rimraf(join(state.snapshotDiffDir)), ctx.rimraf(join(state.snapshotResultDir))]);
|
|
110
|
-
return state;
|
|
111
|
-
}
|
|
112
|
-
export function createSuite(state, testPath, options) {
|
|
113
|
-
const suiteId = getSuiteId(state, testPath, options);
|
|
114
|
-
return {
|
|
115
|
-
suiteId,
|
|
116
|
-
suite: {
|
|
117
|
-
baselineDir: join(state.snapshotBaselineDir, suiteId),
|
|
118
|
-
resultDir: join(state.snapshotResultDir, suiteId),
|
|
119
|
-
diffDir: join(state.snapshotDiffDir, suiteId),
|
|
120
|
-
tasks: {},
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
export function getSuiteId(state, testPath, options) {
|
|
125
|
-
return getSnapshotSubpath(relative(state.projectRoot, testPath), options);
|
|
126
|
-
}
|
|
127
|
-
function getVisOptions(visOptionsRecord, context) {
|
|
128
|
-
return visOptionsRecord[getProjectName(context) ?? '__default'] ?? {};
|
|
129
|
-
}
|
|
130
|
-
function getProjectRoot(context) {
|
|
131
|
-
return context.project.config.root;
|
|
132
|
-
}
|
|
133
|
-
function getProjectId(context) {
|
|
134
|
-
return `${context.project.config.root}/${context.project.config.name}`;
|
|
135
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vis_context.types.d.ts","sourceRoot":"","sources":["../../src/server/vis_context.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACtB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;CAC/C,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,iBAAiB,EAAE,MAAM,CAAA;IACzB,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,MAAM,EAAE,MAAM,CACb,MAAM,EACN;QACC,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,MAAM,CAAA;QACjB,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,MAAM,CACZ,MAAM,EACN;YACC,KAAK,EAAE,MAAM,CAAA;SACb,CACD,CAAA;KACD,CACD,CAAA;CACD,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IAC1C,OAAO,EAAE;QACR,MAAM,EAAE;YACP,IAAI,EAAE,MAAM,CAAA;YACZ,IAAI,EAAE,MAAM,CAAA;YACZ,eAAe,EAAE;gBAChB,cAAc,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;aACtC,CAAA;YACD,WAAW,EAAE,MAAM,CAAA;YACnB,WAAW,EAAE,MAAM,CAAA;SACnB,CAAA;QACD,IAAI,EAAE;YACL,MAAM,EAAE;gBACP,IAAI,CAAC,EAAE;oBACN,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;iBACzB,CAAA;aACD,CAAA;SACD,CAAA;KACD,CAAA;IACD,QAAQ,EAAE;QACT,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAChC,OAAO,CAAC,EAAE;YACT,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;YAC9B,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;YACxC,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SACxC,CAAA;KACD,CAAA;IACD,QAAQ,EAAE,MAAM,CAAA;CAChB,CAAA"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type ComparisonMethod, type SnapshotMeta } from '../client.ts';
|
|
2
|
-
import type { SetupVisSuiteCommand } from '../server/commands/setup_vis_suite.ts';
|
|
3
|
-
/**
|
|
4
|
-
* Visual test configuration on the client side.
|
|
5
|
-
*/
|
|
6
|
-
export type VisClientConfigurator<SM extends SnapshotMeta<ComparisonMethod>> = {
|
|
7
|
-
presets: {
|
|
8
|
-
/**
|
|
9
|
-
* Enable visual testing.
|
|
10
|
-
*
|
|
11
|
-
* auto snapshot is turned off by default.
|
|
12
|
-
* You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.
|
|
13
|
-
*/
|
|
14
|
-
enable(): void;
|
|
15
|
-
/**
|
|
16
|
-
* Enable visual testing.
|
|
17
|
-
*
|
|
18
|
-
* `setAutoSnapshotOptions` will have no effect in this preset.
|
|
19
|
-
*/
|
|
20
|
-
manual(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Enable automatic visual testing.
|
|
23
|
-
*
|
|
24
|
-
* This will take a snapshot after each test.
|
|
25
|
-
*/
|
|
26
|
-
auto(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Enable automatic visual testing with multiple themes.
|
|
29
|
-
*
|
|
30
|
-
* This will take a snapshot after each test for each theme.
|
|
31
|
-
*
|
|
32
|
-
* @param themes A record of theme names and their setup functions.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* vis().presets.theme({
|
|
37
|
-
* light() { document.body.classList.add('light') },
|
|
38
|
-
* dark() { document.body.classList.add('dark') },
|
|
39
|
-
* })
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
theme<M>(themes: Record<string, (options: M & SM) => Promise<boolean> | Promise<void> | boolean | void>): void;
|
|
43
|
-
};
|
|
44
|
-
beforeAll: {
|
|
45
|
-
setup(): Promise<void>;
|
|
46
|
-
};
|
|
47
|
-
afterEach: {
|
|
48
|
-
matchImageSnapshot(): Promise<void>;
|
|
49
|
-
matchPerTheme<M>(themes: Record<string, (options: M & SM) => Promise<boolean> | Promise<void> | boolean | void>): () => Promise<void>;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
export declare function createVis<SM extends SnapshotMeta<ComparisonMethod>>(commands: SetupVisSuiteCommand): VisClientConfigurator<SM>;
|
|
53
|
-
//# sourceMappingURL=create_vis.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/esm/setup/vis.d.ts
DELETED
package/esm/setup/vis.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vis.d.ts","sourceRoot":"","sources":["../../src/setup/vis.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,GAAG,+HAAsB,CAAA"}
|