vitest-plugin-vis 4.0.0 → 4.2.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/auto_snapshots/_ctx.mjs +15 -0
- package/dist/auto_snapshots/_ctx.mjs.map +1 -0
- package/dist/auto_snapshots/_extract_auto_snapshot_options.mjs +23 -0
- package/dist/auto_snapshots/_extract_auto_snapshot_options.mjs.map +1 -0
- package/dist/{auto_snapshot_options-CaQCXDdi.d.mts → auto_snapshots/auto_snapshot_options.d.mts} +5 -4
- package/dist/auto_snapshots/auto_snapshot_options.d.mts.map +1 -0
- package/dist/{auto_snapshot_options-CAD43Zkp.mjs → auto_snapshots/auto_snapshot_options.mjs} +6 -42
- package/dist/auto_snapshots/auto_snapshot_options.mjs.map +1 -0
- package/dist/auto_snapshots/snapshot_meta.d.mts +15 -0
- package/dist/auto_snapshots/snapshot_meta.d.mts.map +1 -0
- package/dist/client/actions/has_image_snapshot_action.d.mts +8 -0
- package/dist/client/actions/has_image_snapshot_action.d.mts.map +1 -0
- package/dist/client/actions/has_image_snapshot_action.mjs +9 -0
- package/dist/client/actions/has_image_snapshot_action.mjs.map +1 -0
- package/dist/client/actions/load_image_snapshot_results_action.d.mts +7 -0
- package/dist/client/actions/load_image_snapshot_results_action.d.mts.map +1 -0
- package/dist/client/actions/load_image_snapshot_results_action.mjs +8 -0
- package/dist/client/actions/load_image_snapshot_results_action.mjs.map +1 -0
- package/dist/client/actions/match_image_snapshot_action.d.mts +9 -0
- package/dist/client/actions/match_image_snapshot_action.d.mts.map +1 -0
- package/dist/client/actions/match_image_snapshot_action.mjs +20 -0
- package/dist/client/actions/match_image_snapshot_action.mjs.map +1 -0
- package/dist/client/actions/match_page_image_snapshot_action.d.mts +9 -0
- package/dist/client/actions/match_page_image_snapshot_action.d.mts.map +1 -0
- package/dist/client/actions/match_page_image_snapshot_action.mjs +14 -0
- package/dist/client/actions/match_page_image_snapshot_action.mjs.map +1 -0
- package/dist/client/expect/_ctx.mjs +15 -0
- package/dist/client/expect/_ctx.mjs.map +1 -0
- package/dist/client/expect/augment.d.mts +10 -0
- package/dist/client/expect/augment.d.mts.map +1 -0
- package/dist/client/expect/expectation_result.d.mts +7 -0
- package/dist/client/expect/expectation_result.d.mts.map +1 -0
- package/dist/client/expect/expectation_result.mjs +9 -0
- package/dist/client/expect/expectation_result.mjs.map +1 -0
- package/dist/client/expect/extend.d.mts +1 -0
- package/dist/client/expect/extend.mjs +9 -0
- package/dist/client/expect/extend.mjs.map +1 -0
- package/dist/client/expect/to_match_image_snapshot.mjs +16 -0
- package/dist/client/expect/to_match_image_snapshot.mjs.map +1 -0
- package/dist/{to_match_image_snapshot.types-p-zilA_M.d.mts → client/expect/to_match_image_snapshot.types.d.mts} +3 -3
- package/dist/client/expect/to_match_image_snapshot.types.d.mts.map +1 -0
- package/dist/client/external/browser/has_render_content.mjs +8 -0
- package/dist/client/external/browser/has_render_content.mjs.map +1 -0
- package/dist/client/external/browser/image_data.mjs +37 -0
- package/dist/client/external/browser/image_data.mjs.map +1 -0
- package/dist/client/external/browser/image_resizer.mjs +32 -0
- package/dist/client/external/browser/image_resizer.mjs.map +1 -0
- package/dist/client/external/browser/selector.mjs +57 -0
- package/dist/client/external/browser/selector.mjs.map +1 -0
- package/dist/client/external/vitest/vitest_browser_context_proxy.mjs +12 -0
- package/dist/client/external/vitest/vitest_browser_context_proxy.mjs.map +1 -0
- package/dist/client/external/vitest/vitest_suite_proxy.d.mts +3 -0
- package/dist/client/external/vitest/vitest_suite_proxy.mjs +11 -0
- package/dist/client/external/vitest/vitest_suite_proxy.mjs.map +1 -0
- package/dist/client/image/align_images.mjs +14 -0
- package/dist/client/image/align_images.mjs.map +1 -0
- package/dist/client/page/_ctx.d.mts +3 -0
- package/dist/client/page/_ctx.mjs +15 -0
- package/dist/client/page/_ctx.mjs.map +1 -0
- package/dist/client/page/augment.d.mts +9 -0
- package/dist/client/page/augment.d.mts.map +1 -0
- package/dist/client/page/extend.d.mts +1 -0
- package/dist/client/page/extend.mjs +13 -0
- package/dist/client/page/extend.mjs.map +1 -0
- package/dist/client/page/has_image_snapshot.d.mts +13 -0
- package/dist/client/page/has_image_snapshot.d.mts.map +1 -0
- package/dist/client/page/has_image_snapshot.mjs +15 -0
- package/dist/client/page/has_image_snapshot.mjs.map +1 -0
- package/dist/client/page/to_match_image_snapshot.d.mts +9 -0
- package/dist/client/page/to_match_image_snapshot.d.mts.map +1 -0
- package/dist/client/page/to_match_image_snapshot.mjs +15 -0
- package/dist/client/page/to_match_image_snapshot.mjs.map +1 -0
- package/dist/client/snapshot/compare_image_snapshot.logic.mjs +14 -0
- package/dist/client/snapshot/compare_image_snapshot.logic.mjs.map +1 -0
- package/dist/client/snapshot/compare_image_snapshot.mjs +63 -0
- package/dist/client/snapshot/compare_image_snapshot.mjs.map +1 -0
- package/dist/client/snapshot/should_take_snapshot.mjs +10 -0
- package/dist/client/snapshot/should_take_snapshot.mjs.map +1 -0
- package/dist/client/suite/_ctx.mjs +13 -0
- package/dist/client/suite/_ctx.mjs.map +1 -0
- package/dist/client/suite/auto_snapshot_matcher.d.mts +12 -0
- package/dist/client/suite/auto_snapshot_matcher.d.mts.map +1 -0
- package/dist/client/suite/auto_snapshot_matcher.mjs +50 -0
- package/dist/client/suite/auto_snapshot_matcher.mjs.map +1 -0
- package/dist/client/task/task_id.d.mts +9 -0
- package/dist/client/task/task_id.d.mts.map +1 -0
- package/dist/client/task/task_id.mjs +15 -0
- package/dist/client/task/task_id.mjs.map +1 -0
- package/dist/client-api.d.mts +13 -141
- package/dist/client-api.mjs +10 -13
- package/dist/{types-Do1N7g4c.d.mts → config/types.d.mts} +8 -9
- package/dist/config/types.d.mts.map +1 -0
- package/dist/config/vis.d.mts +27 -0
- package/dist/config/vis.d.mts.map +1 -0
- package/dist/config/vis.mjs +31 -0
- package/dist/config/vis.mjs.map +1 -0
- package/dist/config.d.mts +5 -28
- package/dist/config.mjs +3 -411
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -4
- package/dist/presets/auto.mjs +4 -7
- package/dist/presets/auto.mjs.map +1 -1
- package/dist/presets/enable.mjs +2 -6
- package/dist/presets/enable.mjs.map +1 -1
- package/dist/presets/manual.mjs +2 -6
- package/dist/presets/manual.mjs.map +1 -1
- package/dist/server/browser_provider/browser_api.mjs +13 -0
- package/dist/server/browser_provider/browser_api.mjs.map +1 -0
- package/dist/server/browser_provider/playwright.mjs +24 -0
- package/dist/server/browser_provider/playwright.mjs.map +1 -0
- package/dist/server/browser_provider/webdriverio.mjs +16 -0
- package/dist/server/browser_provider/webdriverio.mjs.map +1 -0
- package/dist/server/commands/_assertions.mjs +10 -0
- package/dist/server/commands/_assertions.mjs.map +1 -0
- package/dist/server/commands/augment.d.mts +8 -0
- package/dist/server/commands/augment.d.mts.map +1 -0
- package/dist/server/commands/commands.mjs +20 -0
- package/dist/server/commands/commands.mjs.map +1 -0
- package/dist/server/commands/has_image_snapshot.mjs +12 -0
- package/dist/server/commands/has_image_snapshot.mjs.map +1 -0
- package/dist/server/commands/image_snapshot_next_index.mjs +12 -0
- package/dist/server/commands/image_snapshot_next_index.mjs.map +1 -0
- package/dist/server/commands/load_image_snapshot_results.mjs +12 -0
- package/dist/server/commands/load_image_snapshot_results.mjs.map +1 -0
- package/dist/server/commands/prepare_image_snapshot_comparison.mjs +37 -0
- package/dist/server/commands/prepare_image_snapshot_comparison.mjs.map +1 -0
- package/dist/server/commands/prepare_page_image_snapshot_comparison.mjs +27 -0
- package/dist/server/commands/prepare_page_image_snapshot_comparison.mjs.map +1 -0
- package/dist/server/commands/setup_vis_suite.mjs +12 -0
- package/dist/server/commands/setup_vis_suite.mjs.map +1 -0
- package/dist/server/externals/file.mjs +23 -0
- package/dist/server/externals/file.mjs.map +1 -0
- package/dist/server/project.mjs +13 -0
- package/dist/server/project.mjs.map +1 -0
- package/dist/server/snapshot.mjs +29 -0
- package/dist/server/snapshot.mjs.map +1 -0
- package/dist/server/snapshot_path.d.mts +17 -0
- package/dist/server/snapshot_path.d.mts.map +1 -0
- package/dist/{snapshot_path-7GliOSH_.mjs → server/snapshot_path.mjs} +7 -25
- package/dist/server/snapshot_path.mjs.map +1 -0
- package/dist/server/snapshot_writer.mjs +21 -0
- package/dist/server/snapshot_writer.mjs.map +1 -0
- package/dist/server/suite.mjs +82 -0
- package/dist/server/suite.mjs.map +1 -0
- package/dist/server/vis_options.mjs +19 -0
- package/dist/server/vis_options.mjs.map +1 -0
- package/dist/server/vis_server_context.deps.mjs +16 -0
- package/dist/server/vis_server_context.deps.mjs.map +1 -0
- package/dist/server/vis_server_context.logic.mjs +82 -0
- package/dist/server/vis_server_context.logic.mjs.map +1 -0
- package/dist/server/vis_server_context.mjs +8 -0
- package/dist/server/vis_server_context.mjs.map +1 -0
- package/dist/server/vis_server_context.types.d.mts +2 -0
- package/dist/server-utils.d.mts +4 -19
- package/dist/server-utils.mjs +3 -2
- package/dist/setup/create_vis.d.mts +108 -0
- package/dist/setup/create_vis.d.mts.map +1 -0
- package/dist/setup/create_vis.mjs +58 -0
- package/dist/setup/create_vis.mjs.map +1 -0
- package/dist/setup/vis.d.mts +10 -0
- package/dist/setup/vis.d.mts.map +1 -0
- package/dist/setup/vis.mjs +12 -0
- package/dist/setup/vis.mjs.map +1 -0
- package/dist/setup-api.d.mts +4 -0
- package/dist/setup-api.mjs +5 -0
- package/dist/setup.d.mts +8 -105
- package/dist/setup.d.mts.map +1 -1
- package/dist/setup.mjs +12 -7
- package/dist/setup.mjs.map +1 -0
- package/dist/{asserts--HSSlgPD.mjs → shared/asserts.mjs} +2 -2
- package/dist/shared/asserts.mjs.map +1 -0
- package/dist/{base64-CHSENEAO.mjs → shared/base64.mjs} +2 -2
- package/dist/shared/base64.mjs.map +1 -0
- package/dist/shared/commands.types.d.mts +51 -0
- package/dist/shared/commands.types.d.mts.map +1 -0
- package/dist/shared/compare_image.mjs +46 -0
- package/dist/shared/compare_image.mjs.map +1 -0
- package/dist/shared/constants.d.mts +9 -0
- package/dist/shared/constants.d.mts.map +1 -0
- package/dist/{constants-CTBaz8Ml.mjs → shared/constants.mjs} +2 -2
- package/dist/shared/constants.mjs.map +1 -0
- package/dist/shared/convert_threshold_unit.mjs +12 -0
- package/dist/shared/convert_threshold_unit.mjs.map +1 -0
- package/dist/shared/get_max_size.mjs +11 -0
- package/dist/shared/get_max_size.mjs.map +1 -0
- package/dist/shared/is_same_size.mjs +8 -0
- package/dist/shared/is_same_size.mjs.map +1 -0
- package/dist/{trim_common_folder-ModiubEJ.d.mts → shared/trim_common_folder.d.mts} +2 -2
- package/dist/shared/trim_common_folder.d.mts.map +1 -0
- package/dist/shared/trim_common_folder.mjs +23 -0
- package/dist/shared/trim_common_folder.mjs.map +1 -0
- package/dist/{types-DFb23VE1.d.mts → shared/types.d.mts} +39 -20
- package/dist/shared/types.d.mts.map +1 -0
- package/dist/testing/constants.d.mts +12 -0
- package/dist/testing/constants.d.mts.map +1 -0
- package/dist/testing/constants.mjs +65550 -0
- package/dist/{testing.mjs.map → testing/constants.mjs.map} +1 -1
- package/dist/testing.d.mts +2 -12
- package/dist/testing.mjs +2 -65549
- package/package.json +24 -17
- package/readme.md +48 -3
- package/src/{client/ctx.ts → auto_snapshots/_ctx.ts} +1 -3
- package/src/auto_snapshots/_extract_auto_snapshot_options.ts +26 -0
- package/src/{client → auto_snapshots}/auto_snapshot_options.mdx +1 -2
- package/src/{client → auto_snapshots}/auto_snapshot_options.ts +1 -23
- package/src/client/actions/has_image_snapshot_action.ts +1 -1
- package/src/client/actions/load_image_snapshot_results_action.ts +1 -1
- package/src/client/actions/match_image_snapshot_action.ts +6 -6
- package/src/client/actions/match_page_image_snapshot_action.ts +5 -3
- package/src/client/expect/_ctx.ts +10 -0
- package/src/client/expect/to_match_image_snapshot.ts +3 -4
- package/src/client/external/browser/has_render_content.ts +3 -0
- package/src/client/{image_resizer.ts → external/browser/image_resizer.ts} +1 -1
- package/src/client/{vitest_suite_proxy.ts → external/vitest/vitest_suite_proxy.ts} +1 -1
- package/src/client/{align_images.ts → image/align_images.ts} +3 -3
- package/src/client/page/_ctx.ts +12 -0
- package/src/client/page/has_image_snapshot.ts +4 -4
- package/src/client/page/to_match_image_snapshot.ts +3 -4
- package/src/client/{compare_image_snapshot.logic.ts → snapshot/compare_image_snapshot.logic.ts} +2 -2
- package/src/client/{compare_image_snapshot.ts → snapshot/compare_image_snapshot.ts} +23 -10
- package/src/client/snapshot/should_take_snapshot.ts +6 -0
- package/src/client/suite/_ctx.ts +8 -0
- package/src/client/suite/auto_snapshot_matcher.ts +67 -0
- package/src/client-api.ts +3 -2
- package/src/config/overview.mdx +145 -0
- package/src/{shared → config}/trim_common_folder.mdx +1 -1
- package/src/config/types.ts +5 -6
- package/src/config/vis.mdx +313 -0
- package/src/index.ts +1 -1
- package/src/overview.mdx +66 -28
- package/src/server/commands/augment.ts +8 -6
- package/src/server/commands/has_image_snapshot.ts +1 -4
- package/src/server/commands/image_snapshot_next_index.ts +1 -7
- package/src/server/commands/load_image_snapshot_results.ts +1 -20
- package/src/server/commands/prepare_image_snapshot_comparison.ts +10 -56
- package/src/server/commands/prepare_page_image_snapshot_comparison.ts +2 -49
- package/src/server/commands/setup_vis_suite.ts +0 -24
- package/src/server/snapshot_path.ts +3 -1
- package/src/server/vis_server_context.logic.ts +1 -1
- package/src/{setup.create_vis.mdx → setup/create_vis.mdx} +4 -5
- package/src/{client/setup → setup}/create_vis.ts +31 -83
- package/src/setup/overview.mdx +17 -0
- package/src/setup/readme.md +7 -0
- package/src/{setup.vis.mdx → setup/vis.mdx} +15 -18
- package/src/setup-api.ts +5 -0
- package/src/setup.ts +9 -5
- package/src/shared/commands.types.ts +71 -0
- package/src/shared/types.ts +54 -1
- package/dist/asserts--HSSlgPD.mjs.map +0 -1
- package/dist/augment-BJmy1S7i.d.mts +0 -31
- package/dist/augment-BJmy1S7i.d.mts.map +0 -1
- package/dist/auto_snapshot_options-CAD43Zkp.mjs.map +0 -1
- package/dist/auto_snapshot_options-CaQCXDdi.d.mts.map +0 -1
- package/dist/base64-CHSENEAO.mjs.map +0 -1
- package/dist/client-api.d.mts.map +0 -1
- package/dist/client-api.mjs.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/config.mjs.map +0 -1
- package/dist/constants-CTBaz8Ml.mjs.map +0 -1
- package/dist/server-utils.d.mts.map +0 -1
- package/dist/setup-BWgIDtv-.mjs +0 -141
- package/dist/setup-BWgIDtv-.mjs.map +0 -1
- package/dist/setup_vis_suite-C6JGGT7B.d.mts +0 -17
- package/dist/setup_vis_suite-C6JGGT7B.d.mts.map +0 -1
- package/dist/snapshot_path-7GliOSH_.mjs.map +0 -1
- package/dist/src-CSQnlFa9.mjs +0 -1
- package/dist/task_id-DnS9_4Ub.mjs +0 -316
- package/dist/task_id-DnS9_4Ub.mjs.map +0 -1
- package/dist/testing.d.mts.map +0 -1
- package/dist/to_match_image_snapshot.types-p-zilA_M.d.mts.map +0 -1
- package/dist/trim_common_folder-ModiubEJ.d.mts.map +0 -1
- package/dist/types-DFb23VE1.d.mts.map +0 -1
- package/dist/types-Do1N7g4c.d.mts.map +0 -1
- package/dist/vis_server_context.types-Ce1f9vOO.d.mts +0 -1
- package/src/client/image_snapshot_options.ts +0 -6
- package/src/client/setup/vis.ctx.ts +0 -34
- package/src/client/should_take_snapshot.ts +0 -5
- package/src/config.vis.mdx +0 -76
- package/src/server/commands/types.ts +0 -9
- /package/src/{client → auto_snapshots}/snapshot_meta.ts +0 -0
- /package/src/client/{image_data.ts → external/browser/image_data.ts} +0 -0
- /package/src/client/{selector.ts → external/browser/selector.ts} +0 -0
- /package/src/client/{vitest_browser_context_proxy.ts → external/vitest/vitest_browser_context_proxy.ts} +0 -0
- /package/src/client/{task_id.ts → task/task_id.ts} +0 -0
- /package/src/{client/setup → setup}/vis.ts +0 -0
|
@@ -1,27 +1,8 @@
|
|
|
1
|
+
import type { ImageSnapshotResult } from '../../shared/commands.types.ts'
|
|
1
2
|
import { visServerContext } from '../vis_server_context.ts'
|
|
2
3
|
import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
|
|
3
4
|
import { assertTestPathDefined } from './_assertions.ts'
|
|
4
5
|
|
|
5
|
-
export interface ImageSnapshotResult {
|
|
6
|
-
filename: string
|
|
7
|
-
/**
|
|
8
|
-
* The base64 encoded image of the baseline snapshot.
|
|
9
|
-
*/
|
|
10
|
-
baseline?: string | undefined
|
|
11
|
-
/**
|
|
12
|
-
* The base64 encoded image of the result snapshot.
|
|
13
|
-
*/
|
|
14
|
-
result?: string | undefined
|
|
15
|
-
/**
|
|
16
|
-
* The base64 encoded image of the diff snapshot.
|
|
17
|
-
*/
|
|
18
|
-
diff?: string | undefined
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface LoadImageSnapshotResultsCommand {
|
|
22
|
-
loadImageSnapshotResults(taskId: string): Promise<ImageSnapshotResult[]>
|
|
23
|
-
}
|
|
24
|
-
|
|
25
6
|
export const loadImageSnapshotResults: ExtendedBrowserCommand<[taskId: string]> = async (
|
|
26
7
|
context,
|
|
27
8
|
taskId,
|
|
@@ -1,60 +1,14 @@
|
|
|
1
1
|
import { resolve } from 'pathe'
|
|
2
2
|
import { isBase64String } from '../../shared/base64.ts'
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
ImageSnapshotTimeoutOptions,
|
|
6
|
-
PixelComparisonOptions,
|
|
7
|
-
SsimComparisonOptions,
|
|
8
|
-
} from '../../shared/types.ts'
|
|
3
|
+
import type { PrepareImageSnapshotComparisonCommand } from '../../shared/commands.types.ts'
|
|
4
|
+
import type { ImageSnapshotComparisonInfo } from '../../shared/types.ts'
|
|
9
5
|
import { file } from '../externals/file.ts'
|
|
10
6
|
import { getProjectRoot } from '../project.ts'
|
|
11
|
-
import { takeSnapshot
|
|
7
|
+
import { takeSnapshot } from '../snapshot.ts'
|
|
12
8
|
import { snapshotWriter } from '../snapshot_writer.ts'
|
|
13
9
|
import { visServerContext } from '../vis_server_context.ts'
|
|
14
10
|
import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
|
|
15
11
|
import { assertTestPathDefined } from './_assertions.ts'
|
|
16
|
-
import type { MatchImageSnapshotOptions } from './types.ts'
|
|
17
|
-
|
|
18
|
-
export type ImageSnapshotComparisonInfo = {
|
|
19
|
-
/**
|
|
20
|
-
* Path to the project root.
|
|
21
|
-
*/
|
|
22
|
-
projectRoot: string
|
|
23
|
-
/**
|
|
24
|
-
* Path to the baseline image relative to the project root.
|
|
25
|
-
*/
|
|
26
|
-
baselinePath: string
|
|
27
|
-
/**
|
|
28
|
-
* Path to the result image relative to the project root.
|
|
29
|
-
*/
|
|
30
|
-
resultPath: string
|
|
31
|
-
/**
|
|
32
|
-
* Path to the diff image relative to the project root.
|
|
33
|
-
*/
|
|
34
|
-
diffPath: string
|
|
35
|
-
/**
|
|
36
|
-
* Base64 encoded baseline image.
|
|
37
|
-
*/
|
|
38
|
-
baseline: string
|
|
39
|
-
/**
|
|
40
|
-
* Base64 encoded result image.
|
|
41
|
-
*/
|
|
42
|
-
result: string
|
|
43
|
-
/**
|
|
44
|
-
* Base64 encoded diff image.
|
|
45
|
-
*/
|
|
46
|
-
diff?: string | undefined
|
|
47
|
-
} & ImageSnapshotTimeoutOptions &
|
|
48
|
-
FailureThresholdOptions &
|
|
49
|
-
(SsimComparisonOptions | PixelComparisonOptions)
|
|
50
|
-
|
|
51
|
-
export interface PrepareImageSnapshotComparisonCommand {
|
|
52
|
-
prepareImageSnapshotComparison: (
|
|
53
|
-
taskId: string,
|
|
54
|
-
subject: string,
|
|
55
|
-
options?: MatchImageSnapshotOptions | undefined,
|
|
56
|
-
) => Promise<ImageSnapshotComparisonInfo | undefined>
|
|
57
|
-
}
|
|
58
12
|
|
|
59
13
|
export const prepareImageSnapshotComparison: ExtendedBrowserCommand<
|
|
60
14
|
Parameters<PrepareImageSnapshotComparisonCommand['prepareImageSnapshotComparison']>
|
|
@@ -68,20 +22,20 @@ export const prepareImageSnapshotComparison: ExtendedBrowserCommand<
|
|
|
68
22
|
const info = await visServerContext.getSnapshotInfo(context, taskId, options)
|
|
69
23
|
|
|
70
24
|
const baselineBuffer = await file.tryReadFile(resolve(projectRoot, info.baselinePath))
|
|
71
|
-
if (!baselineBuffer) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
25
|
+
if (!baselineBuffer && isBase64String(subject)) {
|
|
26
|
+
await snapshotWriter.writeBase64(resolve(projectRoot, info.resultPath), subject)
|
|
27
|
+
return {
|
|
28
|
+
...info,
|
|
29
|
+
projectRoot,
|
|
30
|
+
result: subject,
|
|
76
31
|
}
|
|
77
|
-
return
|
|
78
32
|
}
|
|
79
33
|
|
|
80
34
|
const resultBuffer = await takeSnapshot(context, projectRoot, info.resultPath, subject, options)
|
|
81
35
|
return {
|
|
82
36
|
...info,
|
|
83
37
|
projectRoot,
|
|
84
|
-
baseline: baselineBuffer
|
|
38
|
+
baseline: baselineBuffer?.toString('base64'),
|
|
85
39
|
result: resultBuffer.toString('base64'),
|
|
86
40
|
}
|
|
87
41
|
}
|
|
@@ -1,53 +1,11 @@
|
|
|
1
1
|
import { resolve } from 'pathe'
|
|
2
|
-
import type {
|
|
3
|
-
FailureThresholdOptions,
|
|
4
|
-
ImageSnapshotTimeoutOptions,
|
|
5
|
-
PixelComparisonOptions,
|
|
6
|
-
SsimComparisonOptions,
|
|
7
|
-
} from '../../shared/types.ts'
|
|
2
|
+
import type { PreparePageImageSnapshotComparisonCommand } from '../../shared/commands.types.ts'
|
|
8
3
|
import { file } from '../externals/file.ts'
|
|
9
4
|
import { getProjectRoot } from '../project.ts'
|
|
10
5
|
import { takePageSnapshot } from '../snapshot.ts'
|
|
11
6
|
import { visServerContext } from '../vis_server_context.ts'
|
|
12
7
|
import type { ExtendedBrowserCommand } from '../vis_server_context.types.ts'
|
|
13
8
|
import { assertTestPathDefined } from './_assertions.ts'
|
|
14
|
-
import type { MatchImageSnapshotOptions } from './types.ts'
|
|
15
|
-
|
|
16
|
-
type ImageSnapshotComparisonInfo = {
|
|
17
|
-
/**
|
|
18
|
-
* Path to the project root.
|
|
19
|
-
*/
|
|
20
|
-
projectRoot: string
|
|
21
|
-
/**
|
|
22
|
-
* Path to the baseline image relative to the project root.
|
|
23
|
-
*/
|
|
24
|
-
baselinePath: string
|
|
25
|
-
/**
|
|
26
|
-
* Path to the result image relative to the project root.
|
|
27
|
-
*/
|
|
28
|
-
resultPath: string
|
|
29
|
-
/**
|
|
30
|
-
* Path to the diff image relative to the project root.
|
|
31
|
-
*/
|
|
32
|
-
diffPath: string
|
|
33
|
-
/**
|
|
34
|
-
* Base64 encoded baseline image.
|
|
35
|
-
*/
|
|
36
|
-
baseline: string
|
|
37
|
-
/**
|
|
38
|
-
* Base64 encoded result image.
|
|
39
|
-
*/
|
|
40
|
-
result: string
|
|
41
|
-
} & ImageSnapshotTimeoutOptions &
|
|
42
|
-
FailureThresholdOptions &
|
|
43
|
-
(SsimComparisonOptions | PixelComparisonOptions)
|
|
44
|
-
|
|
45
|
-
export interface PreparePageImageSnapshotComparisonCommand {
|
|
46
|
-
preparePageImageSnapshotComparison: (
|
|
47
|
-
taskId: string,
|
|
48
|
-
options?: MatchImageSnapshotOptions | undefined,
|
|
49
|
-
) => Promise<ImageSnapshotComparisonInfo | undefined>
|
|
50
|
-
}
|
|
51
9
|
|
|
52
10
|
export const preparePageImageSnapshotComparison: ExtendedBrowserCommand<
|
|
53
11
|
Parameters<PreparePageImageSnapshotComparisonCommand['preparePageImageSnapshotComparison']>
|
|
@@ -60,16 +18,11 @@ export const preparePageImageSnapshotComparison: ExtendedBrowserCommand<
|
|
|
60
18
|
const projectRoot = getProjectRoot(context)
|
|
61
19
|
const info = await visServerContext.getSnapshotInfo(context, taskId, options)
|
|
62
20
|
const baselineBuffer = await file.tryReadFile(resolve(projectRoot, info.baselinePath))
|
|
63
|
-
if (!baselineBuffer) {
|
|
64
|
-
await takePageSnapshot(context, projectRoot, info.baselinePath, options)
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
|
|
68
21
|
const resultBuffer = await takePageSnapshot(context, projectRoot, info.resultPath, options)
|
|
69
22
|
return {
|
|
70
23
|
...info,
|
|
71
24
|
projectRoot,
|
|
72
|
-
baseline: baselineBuffer
|
|
25
|
+
baseline: baselineBuffer?.toString('base64'),
|
|
73
26
|
result: resultBuffer.toString('base64'),
|
|
74
27
|
}
|
|
75
28
|
}
|
|
@@ -1,31 +1,7 @@
|
|
|
1
|
-
import type { Pick } from 'type-plus'
|
|
2
|
-
import type { VisOptions } from '../../config/types.ts'
|
|
3
1
|
import { setupSuite } from '../suite.ts'
|
|
4
2
|
import type { ExtendedBrowserCommand, ExtendedBrowserCommandContext } from '../vis_server_context.types.ts'
|
|
5
3
|
import { assertTestPathDefined } from './_assertions.ts'
|
|
6
4
|
|
|
7
|
-
export interface SetupVisSuiteCommand {
|
|
8
|
-
/**
|
|
9
|
-
* Sets up the visual testing suite by cleaning up previous snapshot and diff output directories.
|
|
10
|
-
* When this command is run for the first time,
|
|
11
|
-
* it will remove the results and diffs directory of all suites.
|
|
12
|
-
*
|
|
13
|
-
* In subsequent runs, it will only remove the results and diffs directory of the current suite.
|
|
14
|
-
*/
|
|
15
|
-
setupVisSuite: () => Promise<
|
|
16
|
-
Pick<
|
|
17
|
-
VisOptions,
|
|
18
|
-
| 'comparisonMethod'
|
|
19
|
-
| 'diffOptions'
|
|
20
|
-
| 'failureThreshold'
|
|
21
|
-
| 'failureThresholdType'
|
|
22
|
-
| 'snapshotKey'
|
|
23
|
-
| 'subject'
|
|
24
|
-
| 'timeout'
|
|
25
|
-
>
|
|
26
|
-
>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
5
|
export const setupVisSuite: ExtendedBrowserCommand<[]> = async (context): Promise<{ subject: string | undefined }> => {
|
|
30
6
|
assertTestPathDefined(context, 'setupVisSuite')
|
|
31
7
|
return setupSuite(context as unknown as ExtendedBrowserCommandContext)
|
|
@@ -6,12 +6,14 @@ import { trimCommonFolder } from '../shared/trim_common_folder.ts'
|
|
|
6
6
|
import type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'
|
|
7
7
|
|
|
8
8
|
export function resolveSnapshotRootDir(browserCommandContext: ExtendedBrowserCommandContext, options: VisOptions) {
|
|
9
|
-
if (!options.snapshotRootDir) return getSnapshotRootDir(
|
|
9
|
+
if (!options.snapshotRootDir) return getSnapshotRootDir()
|
|
10
10
|
const snapshotRootDir = options.snapshotRootDir
|
|
11
11
|
if (typeof snapshotRootDir === 'string') return getSnapshotRootDir(snapshotRootDir)
|
|
12
12
|
const { config } = browserCommandContext.project.browser
|
|
13
13
|
return snapshotRootDir({
|
|
14
14
|
ci,
|
|
15
|
+
rootDir: SNAPSHOT_ROOT_DIR,
|
|
16
|
+
projectName: browserCommandContext.project.name,
|
|
15
17
|
browserName: config.browser.name,
|
|
16
18
|
providerName: browserCommandContext.provider.name,
|
|
17
19
|
platform,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { basename, join, resolve } from 'pathe'
|
|
2
2
|
import { pick } from 'type-plus'
|
|
3
3
|
import type { ImageSnapshotKeyOptions } from '../client-api.ts'
|
|
4
|
-
import type { ImageSnapshotResult } from '
|
|
4
|
+
import type { ImageSnapshotResult } from '../shared/commands.types.ts'
|
|
5
5
|
import { file } from './externals/file.ts'
|
|
6
6
|
import { getSuite, getTaskSubpath } from './suite.ts'
|
|
7
7
|
import { getVisOption } from './vis_options.ts'
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Meta, Markdown ,Canvas} from "@storybook/addon-docs/blocks";
|
|
2
2
|
|
|
3
|
-
<Meta
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/>
|
|
3
|
+
<Meta title="setup/createVis" tags={['deprecated']} />
|
|
4
|
+
|
|
5
|
+
# `createVis`
|
|
7
6
|
|
|
8
7
|
🪦 Deprecated
|
|
9
8
|
|
|
10
9
|
`createVis` in `vitest-plugin-vis/setup` is deprecated.
|
|
11
10
|
|
|
12
|
-
It is moved to
|
|
11
|
+
It is moved to `vitest-plugin-vis/setup-api`.
|
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { shouldTakeSnapshot } from '../should_take_snapshot.ts'
|
|
8
|
-
import type { SnapshotMeta } from '../snapshot_meta.ts'
|
|
9
|
-
import { toTaskId } from '../task_id.ts'
|
|
10
|
-
|
|
11
|
-
export type SetupVisOptions<GM extends Record<string, any> | unknown = unknown> = {
|
|
12
|
-
auto?:
|
|
13
|
-
| boolean
|
|
14
|
-
| (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
|
|
15
|
-
options: SnapshotMeta<C> & M & GM,
|
|
16
|
-
) => Promise<boolean> | Promise<void> | boolean | void)
|
|
17
|
-
| Record<
|
|
18
|
-
string,
|
|
19
|
-
| boolean
|
|
20
|
-
| (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
|
|
21
|
-
options: SnapshotMeta<C> & M & GM,
|
|
22
|
-
) => Promise<boolean> | Promise<void> | boolean | void)
|
|
23
|
-
>
|
|
24
|
-
}
|
|
1
|
+
import { afterEach, beforeAll, expect } from 'vitest'
|
|
2
|
+
import { setAutoSnapshotOptions } from '../auto_snapshots/auto_snapshot_options.ts'
|
|
3
|
+
import type { SnapshotMeta } from '../auto_snapshots/snapshot_meta.ts'
|
|
4
|
+
import { autoSnapshotMatcher } from '../client/suite/auto_snapshot_matcher.ts'
|
|
5
|
+
import type { SetupVisSuiteCommand } from '../shared/commands.types.ts'
|
|
6
|
+
import type { ComparisonMethod, SetupVisOptions } from '../shared/types.ts'
|
|
25
7
|
|
|
26
8
|
/**
|
|
27
9
|
* Visual test configuration on the client side.
|
|
@@ -110,10 +92,19 @@ export type VisClientConfigurator<GM extends Record<string, any> | unknown = unk
|
|
|
110
92
|
): void
|
|
111
93
|
}
|
|
112
94
|
beforeAll: {
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated No known use case.
|
|
97
|
+
*/
|
|
113
98
|
setup(): Promise<void>
|
|
114
99
|
}
|
|
115
100
|
afterEach: {
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated No known use case.
|
|
103
|
+
*/
|
|
116
104
|
matchImageSnapshot(): Promise<void>
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated No known use case.
|
|
107
|
+
*/
|
|
117
108
|
matchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
|
|
118
109
|
themes: Record<
|
|
119
110
|
string,
|
|
@@ -124,106 +115,63 @@ export type VisClientConfigurator<GM extends Record<string, any> | unknown = unk
|
|
|
124
115
|
}
|
|
125
116
|
|
|
126
117
|
export function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand) {
|
|
127
|
-
|
|
118
|
+
const matcher = autoSnapshotMatcher(commands, expect)
|
|
128
119
|
|
|
129
120
|
const vis: VisClientConfigurator<GM> = {
|
|
130
121
|
setup(options) {
|
|
131
122
|
if (!options || options.auto === false) {
|
|
132
|
-
beforeAll(
|
|
123
|
+
beforeAll(matcher.setup)
|
|
133
124
|
} else {
|
|
134
125
|
beforeAll(async () => {
|
|
135
|
-
await
|
|
126
|
+
await matcher.setup()
|
|
136
127
|
setAutoSnapshotOptions(true)
|
|
137
128
|
})
|
|
138
129
|
}
|
|
139
130
|
|
|
140
131
|
if (typeof options?.auto === 'function') {
|
|
141
|
-
afterEach(
|
|
142
|
-
vis.afterEach.matchPerTheme({
|
|
143
|
-
auto: options.auto,
|
|
144
|
-
}),
|
|
145
|
-
)
|
|
132
|
+
afterEach(matcher.createMatcher({ auto: options.auto }))
|
|
146
133
|
} else if (typeof options?.auto === 'object') {
|
|
147
|
-
afterEach(
|
|
134
|
+
afterEach(matcher.createMatcher(options.auto))
|
|
148
135
|
} else {
|
|
149
|
-
afterEach(
|
|
136
|
+
afterEach(matcher.createMatcher({ async auto() {} }))
|
|
150
137
|
}
|
|
151
138
|
},
|
|
152
139
|
presets: {
|
|
153
140
|
enable() {
|
|
154
|
-
beforeAll(
|
|
155
|
-
afterEach(
|
|
141
|
+
beforeAll(matcher.setup)
|
|
142
|
+
afterEach(matcher.createMatcher({ async auto() {} }))
|
|
156
143
|
},
|
|
157
144
|
manual() {
|
|
158
|
-
beforeAll(
|
|
145
|
+
beforeAll(matcher.setup)
|
|
159
146
|
},
|
|
160
147
|
auto() {
|
|
161
148
|
beforeAll(async () => {
|
|
162
|
-
await
|
|
149
|
+
await matcher.setup()
|
|
163
150
|
setAutoSnapshotOptions(true)
|
|
164
151
|
})
|
|
165
|
-
afterEach(
|
|
152
|
+
afterEach(matcher.createMatcher({ async auto() {} }))
|
|
166
153
|
},
|
|
167
154
|
theme(themes) {
|
|
168
155
|
beforeAll(async () => {
|
|
169
|
-
await
|
|
156
|
+
await matcher.setup()
|
|
170
157
|
setAutoSnapshotOptions(true)
|
|
171
158
|
})
|
|
172
|
-
afterEach(
|
|
159
|
+
afterEach(matcher.createMatcher(themes))
|
|
173
160
|
},
|
|
174
161
|
},
|
|
175
162
|
beforeAll: {
|
|
176
163
|
async setup() {
|
|
177
|
-
|
|
164
|
+
await matcher.setup()
|
|
178
165
|
},
|
|
179
166
|
},
|
|
180
167
|
afterEach: {
|
|
181
168
|
async matchImageSnapshot() {
|
|
182
|
-
return
|
|
169
|
+
return matcher.createMatcher({ async auto() {} })()
|
|
183
170
|
},
|
|
184
171
|
matchPerTheme(themes) {
|
|
185
|
-
return
|
|
186
|
-
const test = ctx.getCurrentTest()
|
|
187
|
-
if ((test?.result?.errors?.length ?? 0) > 0) return
|
|
188
|
-
|
|
189
|
-
const meta = extractAutoSnapshotOptions(test)
|
|
190
|
-
if (!shouldTakeSnapshot(meta)) return
|
|
191
|
-
const errors: Array<[string, Error]> = []
|
|
192
|
-
for (const themeId in themes) {
|
|
193
|
-
try {
|
|
194
|
-
await new Promise((a) => setTimeout(a, 10))
|
|
195
|
-
const theme = themes[themeId]
|
|
196
|
-
const r = typeof theme === 'function' ? await theme(meta! as any) : theme
|
|
197
|
-
if (r === false) continue
|
|
198
|
-
await test!.context.expect(getSubject(meta?.subject ?? subject)).toMatchImageSnapshot({
|
|
199
|
-
...meta,
|
|
200
|
-
snapshotKey: meta?.snapshotKey ?? themeId,
|
|
201
|
-
})
|
|
202
|
-
} catch (error) {
|
|
203
|
-
errors.push([themeId, error as Error])
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (errors.length > 0) {
|
|
207
|
-
if (errors.length === 1) throw errors[0]![1]
|
|
208
|
-
const taskId = toTaskId(test!)
|
|
209
|
-
throw new AggregateError(
|
|
210
|
-
errors,
|
|
211
|
-
dedent`Snapshot \`${taskId}\` mismatched
|
|
212
|
-
|
|
213
|
-
${errors
|
|
214
|
-
.map(([themeId, error]) => {
|
|
215
|
-
return `Theme \`${themeId}\` failed: ${error.message}`
|
|
216
|
-
})
|
|
217
|
-
.join('\n\n')}`,
|
|
218
|
-
)
|
|
219
|
-
}
|
|
220
|
-
}
|
|
172
|
+
return matcher.createMatcher(themes)
|
|
221
173
|
},
|
|
222
174
|
},
|
|
223
175
|
}
|
|
224
176
|
return vis
|
|
225
177
|
}
|
|
226
|
-
|
|
227
|
-
function getSubject(selectors: string | undefined) {
|
|
228
|
-
return selectors ? (document.querySelector(selectors) ?? document.body) : document.body
|
|
229
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="setup" />
|
|
4
|
+
|
|
5
|
+
# Overview
|
|
6
|
+
|
|
7
|
+
`vitest-plugin-vis/setup` provides the API to setup the plugin on the client side.
|
|
8
|
+
|
|
9
|
+
It provides the API you needed in `vitest.setup.ts`.
|
|
10
|
+
|
|
11
|
+
## Augmentation
|
|
12
|
+
|
|
13
|
+
When you import `vitest-plugin-vis/setup`, it will augment `expect` and `page` to provide methods for visual testing.
|
|
14
|
+
|
|
15
|
+
- `expect().toMatchImageSnapshot()`: Match the image snapshot.
|
|
16
|
+
- `page.toMatchImageSnapshot()`: Match the image snapshot.
|
|
17
|
+
- `page.hasImageSnapshot()`: Check if the image snapshot exists.
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { Meta
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
2
|
|
|
3
|
-
<Meta title="
|
|
3
|
+
<Meta title="setup/vis" />
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# `vis`
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
// vitest.setup.ts
|
|
9
|
-
import { vis } from 'vitest-plugin-vis/setup'
|
|
10
|
-
|
|
11
|
-
vis.setup()
|
|
12
|
-
```
|
|
7
|
+
`vis` object from `vitest-plugin-vis/setup` provides the API to setup the plugin on the client side.
|
|
13
8
|
|
|
14
9
|
## Basic Setup
|
|
15
10
|
|
|
@@ -23,7 +18,7 @@ vis.setup()
|
|
|
23
18
|
// Enable auto snapshots for all tests
|
|
24
19
|
vis.setup({ auto: true })
|
|
25
20
|
|
|
26
|
-
// Disable auto snapshots (same as vis.setup())
|
|
21
|
+
// Disable auto snapshots (same as `vis.setup()`)
|
|
27
22
|
vis.setup({ auto: false })
|
|
28
23
|
```
|
|
29
24
|
|
|
@@ -46,6 +41,8 @@ vis.setup({
|
|
|
46
41
|
})
|
|
47
42
|
```
|
|
48
43
|
|
|
44
|
+
The function will be called during the `afterEach()` phase of the test.
|
|
45
|
+
|
|
49
46
|
## Multi-Theme Setup
|
|
50
47
|
|
|
51
48
|
Set up automatic snapshots for multiple themes (e.g., light and dark mode):
|
|
@@ -56,11 +53,11 @@ import { vis } from 'vitest-plugin-vis/setup'
|
|
|
56
53
|
|
|
57
54
|
vis.setup({
|
|
58
55
|
auto: {
|
|
59
|
-
async
|
|
56
|
+
light: async () => {
|
|
60
57
|
document.body.classList.remove('dark')
|
|
61
58
|
document.body.classList.add('light')
|
|
62
59
|
},
|
|
63
|
-
async
|
|
60
|
+
dark: async () => {
|
|
64
61
|
document.body.classList.add('dark')
|
|
65
62
|
document.body.classList.remove('light')
|
|
66
63
|
}
|
|
@@ -78,11 +75,11 @@ import { vis } from 'vitest-plugin-vis/setup'
|
|
|
78
75
|
|
|
79
76
|
vis.setup({
|
|
80
77
|
auto: {
|
|
81
|
-
async
|
|
78
|
+
light: async ({ meta }) => {
|
|
82
79
|
if (meta['skipLight']) return false
|
|
83
80
|
document.body.classList.remove('dark')
|
|
84
81
|
},
|
|
85
|
-
async
|
|
82
|
+
dark: async ({ meta }) => {
|
|
86
83
|
if (meta['skipDark']) return false
|
|
87
84
|
document.body.classList.add('dark')
|
|
88
85
|
}
|
|
@@ -100,19 +97,19 @@ import { vis } from 'vitest-plugin-vis/setup'
|
|
|
100
97
|
|
|
101
98
|
vis.setup({
|
|
102
99
|
auto: {
|
|
103
|
-
async
|
|
100
|
+
desktop: async () => {
|
|
104
101
|
document.body.style.width = '1200px'
|
|
105
102
|
document.body.classList.add('desktop')
|
|
106
103
|
},
|
|
107
|
-
async
|
|
104
|
+
tablet: async () => {
|
|
108
105
|
document.body.style.width = '768px'
|
|
109
106
|
document.body.classList.add('tablet')
|
|
110
107
|
},
|
|
111
|
-
async
|
|
108
|
+
mobile: async () => {
|
|
112
109
|
document.body.style.width = '375px'
|
|
113
110
|
document.body.classList.add('mobile')
|
|
114
111
|
},
|
|
115
|
-
|
|
112
|
+
'dark-desktop': async ({ meta }) => {
|
|
116
113
|
if (meta['skipDark']) return false
|
|
117
114
|
document.body.style.width = '1200px'
|
|
118
115
|
document.body.classList.add('desktop', 'dark')
|
package/src/setup-api.ts
ADDED
package/src/setup.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import './client/expect/extend.ts'
|
|
3
|
-
import './client/page/extend.ts'
|
|
1
|
+
import './setup-api.ts'
|
|
4
2
|
|
|
5
|
-
export * from './
|
|
6
|
-
|
|
3
|
+
export * from './setup/vis.ts'
|
|
4
|
+
|
|
5
|
+
import { createVis as createVisDeprecated } from './setup/create_vis.ts'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `createVis` from `vitest-plugin-vis/setup-api` instead.
|
|
9
|
+
*/
|
|
10
|
+
export const createVis = createVisDeprecated
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Pick } from 'type-plus'
|
|
2
|
+
import type { VisOptions } from '../config/types.ts'
|
|
3
|
+
import type { ImageSnapshotComparisonInfo, MatchImageSnapshotOptions } from './types.ts'
|
|
4
|
+
|
|
5
|
+
export interface PrepareImageSnapshotComparisonCommand {
|
|
6
|
+
prepareImageSnapshotComparison: (
|
|
7
|
+
taskId: string,
|
|
8
|
+
subject: string,
|
|
9
|
+
options?: MatchImageSnapshotOptions | undefined,
|
|
10
|
+
) => Promise<ImageSnapshotComparisonInfo>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PreparePageImageSnapshotComparisonCommand {
|
|
14
|
+
preparePageImageSnapshotComparison: (
|
|
15
|
+
taskId: string,
|
|
16
|
+
options?: MatchImageSnapshotOptions | undefined,
|
|
17
|
+
) => Promise<ImageSnapshotComparisonInfo>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SetupVisSuiteCommand {
|
|
21
|
+
/**
|
|
22
|
+
* Sets up the visual testing suite by cleaning up previous snapshot and diff output directories.
|
|
23
|
+
* When this command is run for the first time,
|
|
24
|
+
* it will remove the results and diffs directory of all suites.
|
|
25
|
+
*
|
|
26
|
+
* In subsequent runs, it will only remove the results and diffs directory of the current suite.
|
|
27
|
+
*/
|
|
28
|
+
setupVisSuite: () => Promise<
|
|
29
|
+
Pick<
|
|
30
|
+
VisOptions,
|
|
31
|
+
| 'comparisonMethod'
|
|
32
|
+
| 'diffOptions'
|
|
33
|
+
| 'failureThreshold'
|
|
34
|
+
| 'failureThresholdType'
|
|
35
|
+
| 'snapshotKey'
|
|
36
|
+
| 'subject'
|
|
37
|
+
| 'timeout'
|
|
38
|
+
>
|
|
39
|
+
>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface LoadImageSnapshotResultsCommand {
|
|
43
|
+
loadImageSnapshotResults(taskId: string): Promise<ImageSnapshotResult[]>
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ImageSnapshotResult {
|
|
47
|
+
filename: string
|
|
48
|
+
/**
|
|
49
|
+
* The base64 encoded image of the baseline snapshot.
|
|
50
|
+
*/
|
|
51
|
+
baseline?: string | undefined
|
|
52
|
+
/**
|
|
53
|
+
* The base64 encoded image of the result snapshot.
|
|
54
|
+
*/
|
|
55
|
+
result?: string | undefined
|
|
56
|
+
/**
|
|
57
|
+
* The base64 encoded image of the diff snapshot.
|
|
58
|
+
*/
|
|
59
|
+
diff?: string | undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface HasImageSnapshotCommand {
|
|
63
|
+
hasImageSnapshot(taskId: string, snapshotKey: string | undefined): Promise<boolean>
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ImageSnapshotNextIndexCommand {
|
|
67
|
+
/**
|
|
68
|
+
* Get the index of the snapshot image to be created.
|
|
69
|
+
*/
|
|
70
|
+
imageSnapshotNextIndex(taskId: string): Promise<number>
|
|
71
|
+
}
|