vitest-plugin-vis 3.5.1 → 4.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/dist/asserts--HSSlgPD.mjs +8 -0
- package/dist/asserts--HSSlgPD.mjs.map +1 -0
- package/dist/augment-BJmy1S7i.d.mts +31 -0
- package/dist/augment-BJmy1S7i.d.mts.map +1 -0
- package/dist/auto_snapshot_options-CAD43Zkp.mjs +90 -0
- package/dist/auto_snapshot_options-CAD43Zkp.mjs.map +1 -0
- package/dist/auto_snapshot_options-CaQCXDdi.d.mts +45 -0
- package/dist/auto_snapshot_options-CaQCXDdi.d.mts.map +1 -0
- package/dist/base64-CHSENEAO.mjs +8 -0
- package/dist/base64-CHSENEAO.mjs.map +1 -0
- package/dist/client-api.d.mts +141 -0
- package/dist/client-api.d.mts.map +1 -0
- package/dist/client-api.mjs +14 -0
- package/dist/client-api.mjs.map +1 -0
- package/dist/config.d.mts +28 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +412 -0
- package/dist/config.mjs.map +1 -0
- package/dist/constants-CTBaz8Ml.mjs +10 -0
- package/dist/constants-CTBaz8Ml.mjs.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +6 -0
- package/dist/presets/auto.d.mts +1 -0
- package/dist/presets/auto.mjs +19 -0
- package/dist/presets/auto.mjs.map +1 -0
- package/dist/presets/enable.d.mts +1 -0
- package/dist/presets/enable.mjs +15 -0
- package/dist/presets/enable.mjs.map +1 -0
- package/dist/presets/manual.d.mts +1 -0
- package/dist/presets/manual.mjs +15 -0
- package/dist/presets/manual.mjs.map +1 -0
- package/dist/server-utils.d.mts +19 -0
- package/dist/server-utils.d.mts.map +1 -0
- package/dist/server-utils.mjs +4 -0
- package/dist/setup-BWgIDtv-.mjs +141 -0
- package/dist/setup-BWgIDtv-.mjs.map +1 -0
- package/dist/setup.d.mts +110 -0
- package/dist/setup.d.mts.map +1 -0
- package/dist/setup.mjs +8 -0
- package/dist/setup_vis_suite-C6JGGT7B.d.mts +17 -0
- package/dist/setup_vis_suite-C6JGGT7B.d.mts.map +1 -0
- package/dist/snapshot_path-7GliOSH_.mjs +58 -0
- package/dist/snapshot_path-7GliOSH_.mjs.map +1 -0
- package/dist/src-CSQnlFa9.mjs +1 -0
- package/dist/task_id-DnS9_4Ub.mjs +316 -0
- package/dist/task_id-DnS9_4Ub.mjs.map +1 -0
- package/dist/testing.d.mts +12 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +65550 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/to_match_image_snapshot.types-p-zilA_M.d.mts +9 -0
- package/dist/to_match_image_snapshot.types-p-zilA_M.d.mts.map +1 -0
- package/dist/trim_common_folder-ModiubEJ.d.mts +9 -0
- package/dist/trim_common_folder-ModiubEJ.d.mts.map +1 -0
- package/dist/types-DFb23VE1.d.mts +110 -0
- package/dist/types-DFb23VE1.d.mts.map +1 -0
- package/dist/types-Do1N7g4c.d.mts +63 -0
- package/dist/types-Do1N7g4c.d.mts.map +1 -0
- package/dist/vis_server_context.types-Ce1f9vOO.d.mts +1 -0
- package/package.json +55 -39
- package/readme.md +58 -6
- package/src/client/actions/match_image_snapshot_action.ts +1 -1
- package/src/client/actions/match_page_image_snapshot_action.ts +1 -1
- package/src/client/auto_snapshot_options.ts +16 -1
- package/src/client/compare_image_snapshot.ts +1 -1
- package/src/client/expect/to_match_image_snapshot.ts +1 -1
- package/src/client/page/extend.ts +1 -1
- package/src/client/page/has_image_snapshot.mdx +1 -1
- package/src/client/page/has_image_snapshot.ts +1 -1
- package/src/client/page/to_match_image_snapshot.mdx +1 -1
- package/src/client/page/to_match_image_snapshot.ts +1 -1
- package/src/client/setup/create_vis.ts +16 -14
- package/src/client/setup/vis.ctx.ts +4 -3
- package/src/client/setup/vis.ts +1 -1
- package/src/client/snapshot_meta.ts +5 -0
- package/src/client/vitest_browser_context_proxy.ts +3 -3
- package/src/config/vis.ts +4 -4
- package/src/server/browser_provider/browser_api.ts +2 -2
- package/src/server/browser_provider/playwright.ts +6 -4
- package/src/server/browser_provider/webdriverio.ts +3 -3
- package/src/server/commands/_assertions.ts +3 -3
- package/src/server/commands/augment.ts +1 -1
- package/src/server/commands/has_image_snapshot.ts +2 -2
- package/src/server/commands/image_snapshot_next_index.ts +2 -2
- package/src/server/commands/load_image_snapshot_results.ts +2 -3
- package/src/server/commands/prepare_image_snapshot_comparison.ts +2 -2
- package/src/server/commands/prepare_page_image_snapshot_comparison.ts +2 -2
- package/src/server/commands/setup_vis_suite.ts +3 -3
- package/src/server/project.ts +8 -7
- package/src/server/snapshot.ts +4 -4
- package/src/server/snapshot_path.ts +6 -5
- package/src/server/suite.ts +7 -12
- package/src/server/testing/stubBrowserCommandContext.ts +16 -0
- package/src/{testing → server/testing}/stubSuite.ts +7 -9
- package/src/server/testing/stubUserConfig.ts +6 -0
- package/src/server/vis_options.ts +4 -5
- package/src/server/vis_server_context.logic.ts +7 -7
- package/src/server/vis_server_context.types.ts +31 -26
- package/src/shared/types.ts +2 -0
- package/src/testing.ts +0 -1
- package/esm/client/actions/has_image_snapshot_action.d.ts +0 -4
- package/esm/client/actions/has_image_snapshot_action.d.ts.map +0 -1
- package/esm/client/actions/has_image_snapshot_action.js +0 -6
- package/esm/client/actions/load_image_snapshot_results_action.d.ts +0 -3
- package/esm/client/actions/load_image_snapshot_results_action.d.ts.map +0 -1
- package/esm/client/actions/load_image_snapshot_results_action.js +0 -3
- package/esm/client/actions/match_image_snapshot_action.d.ts +0 -6
- package/esm/client/actions/match_image_snapshot_action.d.ts.map +0 -1
- package/esm/client/actions/match_image_snapshot_action.js +0 -20
- package/esm/client/actions/match_page_image_snapshot_action.d.ts +0 -6
- package/esm/client/actions/match_page_image_snapshot_action.d.ts.map +0 -1
- package/esm/client/actions/match_page_image_snapshot_action.js +0 -9
- package/esm/client/align_images.d.ts +0 -2
- package/esm/client/align_images.d.ts.map +0 -1
- package/esm/client/align_images.js +0 -10
- package/esm/client/auto_snapshot_options.d.ts +0 -29
- package/esm/client/auto_snapshot_options.d.ts.map +0 -1
- package/esm/client/auto_snapshot_options.js +0 -49
- package/esm/client/compare_image_snapshot.d.ts +0 -6
- package/esm/client/compare_image_snapshot.d.ts.map +0 -1
- package/esm/client/compare_image_snapshot.js +0 -52
- package/esm/client/compare_image_snapshot.logic.d.ts +0 -3
- package/esm/client/compare_image_snapshot.logic.d.ts.map +0 -1
- package/esm/client/compare_image_snapshot.logic.js +0 -12
- package/esm/client/ctx.d.ts +0 -7
- package/esm/client/ctx.d.ts.map +0 -1
- package/esm/client/ctx.js +0 -11
- package/esm/client/expect/augment.d.ts +0 -8
- package/esm/client/expect/augment.d.ts.map +0 -1
- package/esm/client/expect/augment.js +0 -1
- package/esm/client/expect/expectation_result.d.ts +0 -3
- package/esm/client/expect/expectation_result.d.ts.map +0 -1
- package/esm/client/expect/expectation_result.js +0 -5
- package/esm/client/expect/extend.d.ts +0 -2
- package/esm/client/expect/extend.d.ts.map +0 -1
- package/esm/client/expect/extend.js +0 -4
- package/esm/client/expect/to_match_image_snapshot.d.ts +0 -9
- package/esm/client/expect/to_match_image_snapshot.d.ts.map +0 -1
- package/esm/client/expect/to_match_image_snapshot.js +0 -21
- package/esm/client/expect/to_match_image_snapshot.types.d.ts +0 -5
- package/esm/client/expect/to_match_image_snapshot.types.d.ts.map +0 -1
- package/esm/client/expect/to_match_image_snapshot.types.js +0 -1
- package/esm/client/image_data.d.ts +0 -3
- package/esm/client/image_data.d.ts.map +0 -1
- package/esm/client/image_data.js +0 -33
- package/esm/client/image_resizer.d.ts +0 -9
- package/esm/client/image_resizer.d.ts.map +0 -1
- package/esm/client/image_resizer.js +0 -49
- package/esm/client/image_snapshot_options.d.ts +0 -2
- package/esm/client/image_snapshot_options.d.ts.map +0 -1
- package/esm/client/image_snapshot_options.js +0 -6
- package/esm/client/page/augment.d.ts +0 -7
- package/esm/client/page/augment.d.ts.map +0 -1
- package/esm/client/page/augment.js +0 -1
- package/esm/client/page/extend.d.ts +0 -2
- package/esm/client/page/extend.d.ts.map +0 -1
- package/esm/client/page/extend.js +0 -5
- package/esm/client/page/has_image_snapshot.d.ts +0 -10
- package/esm/client/page/has_image_snapshot.d.ts.map +0 -1
- package/esm/client/page/has_image_snapshot.js +0 -15
- package/esm/client/page/to_match_image_snapshot.d.ts +0 -6
- package/esm/client/page/to_match_image_snapshot.d.ts.map +0 -1
- package/esm/client/page/to_match_image_snapshot.js +0 -15
- package/esm/client/selector.d.ts +0 -7
- package/esm/client/selector.d.ts.map +0 -1
- package/esm/client/selector.js +0 -97
- package/esm/client/setup/create_vis.d.ts +0 -96
- package/esm/client/setup/create_vis.d.ts.map +0 -1
- package/esm/client/setup/create_vis.js +0 -109
- package/esm/client/setup/vis.ctx.d.ts +0 -12
- package/esm/client/setup/vis.ctx.d.ts.map +0 -1
- package/esm/client/setup/vis.ctx.js +0 -32
- package/esm/client/setup/vis.d.ts +0 -5
- package/esm/client/setup/vis.d.ts.map +0 -1
- package/esm/client/setup/vis.js +0 -6
- package/esm/client/should_take_snapshot.d.ts +0 -3
- package/esm/client/should_take_snapshot.d.ts.map +0 -1
- package/esm/client/should_take_snapshot.js +0 -3
- package/esm/client/snapshot_meta.d.ts +0 -6
- package/esm/client/snapshot_meta.d.ts.map +0 -1
- package/esm/client/snapshot_meta.js +0 -1
- package/esm/client/task_id.d.ts +0 -7
- package/esm/client/task_id.d.ts.map +0 -1
- package/esm/client/task_id.js +0 -10
- package/esm/client/vitest_browser_context_proxy.d.ts +0 -32
- package/esm/client/vitest_browser_context_proxy.d.ts.map +0 -1
- package/esm/client/vitest_browser_context_proxy.js +0 -11
- package/esm/client/vitest_suite_proxy.d.ts +0 -7
- package/esm/client/vitest_suite_proxy.d.ts.map +0 -1
- package/esm/client/vitest_suite_proxy.js +0 -8
- package/esm/client-api.d.ts +0 -12
- package/esm/client-api.d.ts.map +0 -1
- package/esm/client-api.js +0 -9
- package/esm/commands.d.ts +0 -5
- package/esm/commands.d.ts.map +0 -1
- package/esm/commands.js +0 -4
- package/esm/config/types.d.ts +0 -60
- package/esm/config/types.d.ts.map +0 -1
- package/esm/config/types.js +0 -1
- package/esm/config/vis.d.ts +0 -28
- package/esm/config/vis.d.ts.map +0 -1
- package/esm/config/vis.js +0 -27
- package/esm/config.d.ts +0 -4
- package/esm/config.d.ts.map +0 -1
- package/esm/config.js +0 -2
- package/esm/index.d.ts +0 -5
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -4
- package/esm/presets/auto.d.ts +0 -2
- package/esm/presets/auto.d.ts.map +0 -1
- package/esm/presets/auto.js +0 -8
- package/esm/presets/enable.d.ts +0 -2
- package/esm/presets/enable.d.ts.map +0 -1
- package/esm/presets/enable.js +0 -4
- package/esm/presets/manual.d.ts +0 -2
- package/esm/presets/manual.d.ts.map +0 -1
- package/esm/presets/manual.js +0 -4
- package/esm/server/browser_provider/browser_api.d.ts +0 -3
- package/esm/server/browser_provider/browser_api.d.ts.map +0 -1
- package/esm/server/browser_provider/browser_api.js +0 -11
- package/esm/server/browser_provider/playwright.d.ts +0 -4
- package/esm/server/browser_provider/playwright.d.ts.map +0 -1
- package/esm/server/browser_provider/playwright.js +0 -18
- package/esm/server/browser_provider/types.d.ts +0 -10
- package/esm/server/browser_provider/types.d.ts.map +0 -1
- package/esm/server/browser_provider/types.js +0 -1
- package/esm/server/browser_provider/webdriverio.d.ts +0 -4
- package/esm/server/browser_provider/webdriverio.d.ts.map +0 -1
- package/esm/server/browser_provider/webdriverio.js +0 -12
- package/esm/server/commands/_assertions.d.ts +0 -5
- package/esm/server/commands/_assertions.d.ts.map +0 -1
- package/esm/server/commands/_assertions.js +0 -11
- package/esm/server/commands/augment.d.ts +0 -11
- package/esm/server/commands/augment.d.ts.map +0 -1
- package/esm/server/commands/augment.js +0 -1
- package/esm/server/commands/commands.d.ts +0 -9
- package/esm/server/commands/commands.d.ts.map +0 -1
- package/esm/server/commands/commands.js +0 -14
- package/esm/server/commands/has_image_snapshot.d.ts +0 -6
- package/esm/server/commands/has_image_snapshot.d.ts.map +0 -1
- package/esm/server/commands/has_image_snapshot.js +0 -6
- package/esm/server/commands/image_snapshot_next_index.d.ts +0 -9
- package/esm/server/commands/image_snapshot_next_index.d.ts.map +0 -1
- package/esm/server/commands/image_snapshot_next_index.js +0 -6
- package/esm/server/commands/load_image_snapshot_results.d.ts +0 -21
- package/esm/server/commands/load_image_snapshot_results.d.ts.map +0 -1
- package/esm/server/commands/load_image_snapshot_results.js +0 -6
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts +0 -38
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +0 -1
- package/esm/server/commands/prepare_image_snapshot_comparison.js +0 -34
- package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts +0 -35
- package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts.map +0 -1
- package/esm/server/commands/prepare_page_image_snapshot_comparison.js +0 -27
- package/esm/server/commands/setup_vis_suite.d.ts +0 -15
- package/esm/server/commands/setup_vis_suite.d.ts.map +0 -1
- package/esm/server/commands/setup_vis_suite.js +0 -6
- package/esm/server/commands/types.d.ts +0 -3
- package/esm/server/commands/types.d.ts.map +0 -1
- package/esm/server/commands/types.js +0 -1
- package/esm/server/externals/file.d.ts +0 -10
- package/esm/server/externals/file.d.ts.map +0 -1
- package/esm/server/externals/file.js +0 -20
- package/esm/server/project.d.ts +0 -21
- package/esm/server/project.d.ts.map +0 -1
- package/esm/server/project.js +0 -13
- package/esm/server/snapshot.d.ts +0 -6
- package/esm/server/snapshot.d.ts.map +0 -1
- package/esm/server/snapshot.js +0 -29
- package/esm/server/snapshot_path.d.ts +0 -14
- package/esm/server/snapshot_path.d.ts.map +0 -1
- package/esm/server/snapshot_path.js +0 -34
- package/esm/server/snapshot_writer.d.ts +0 -13
- package/esm/server/snapshot_writer.d.ts.map +0 -1
- package/esm/server/snapshot_writer.js +0 -15
- package/esm/server/suite.d.ts +0 -54
- package/esm/server/suite.d.ts.map +0 -1
- package/esm/server/suite.js +0 -73
- package/esm/server/vis_options.d.ts +0 -19
- package/esm/server/vis_options.d.ts.map +0 -1
- package/esm/server/vis_options.js +0 -14
- package/esm/server/vis_server_context.d.ts +0 -50
- package/esm/server/vis_server_context.d.ts.map +0 -1
- package/esm/server/vis_server_context.deps.d.ts +0 -29
- package/esm/server/vis_server_context.deps.d.ts.map +0 -1
- package/esm/server/vis_server_context.deps.js +0 -10
- package/esm/server/vis_server_context.js +0 -2
- package/esm/server/vis_server_context.logic.d.ts +0 -53
- package/esm/server/vis_server_context.logic.d.ts.map +0 -1
- package/esm/server/vis_server_context.logic.js +0 -79
- package/esm/server/vis_server_context.types.d.ts +0 -54
- package/esm/server/vis_server_context.types.d.ts.map +0 -1
- package/esm/server/vis_server_context.types.js +0 -1
- package/esm/server-utils.d.ts +0 -4
- package/esm/server-utils.d.ts.map +0 -1
- package/esm/server-utils.js +0 -3
- package/esm/setup.d.ts +0 -5
- package/esm/setup.d.ts.map +0 -1
- package/esm/setup.js +0 -5
- package/esm/shared/asserts.d.ts +0 -2
- package/esm/shared/asserts.d.ts.map +0 -1
- package/esm/shared/asserts.js +0 -5
- package/esm/shared/base64.d.ts +0 -2
- package/esm/shared/base64.d.ts.map +0 -1
- package/esm/shared/base64.js +0 -3
- package/esm/shared/compare_image.d.ts +0 -6
- package/esm/shared/compare_image.d.ts.map +0 -1
- package/esm/shared/compare_image.js +0 -42
- package/esm/shared/constants.d.ts +0 -6
- package/esm/shared/constants.d.ts.map +0 -1
- package/esm/shared/constants.js +0 -5
- package/esm/shared/convert_threshold_unit.d.ts +0 -6
- package/esm/shared/convert_threshold_unit.d.ts.map +0 -1
- package/esm/shared/convert_threshold_unit.js +0 -10
- package/esm/shared/get_max_size.d.ts +0 -11
- package/esm/shared/get_max_size.d.ts.map +0 -1
- package/esm/shared/get_max_size.js +0 -5
- package/esm/shared/is_same_size.d.ts +0 -8
- package/esm/shared/is_same_size.d.ts.map +0 -1
- package/esm/shared/is_same_size.js +0 -3
- package/esm/shared/trim_common_folder.d.ts +0 -6
- package/esm/shared/trim_common_folder.d.ts.map +0 -1
- package/esm/shared/trim_common_folder.js +0 -11
- package/esm/shared/types.d.ts +0 -90
- package/esm/shared/types.d.ts.map +0 -1
- package/esm/shared/types.js +0 -1
- package/esm/testing/constants.d.ts +0 -9
- package/esm/testing/constants.d.ts.map +0 -1
- package/esm/testing/constants.js +0 -1933
- package/esm/testing/stubBrowserCommandContext.d.ts +0 -8
- package/esm/testing/stubBrowserCommandContext.d.ts.map +0 -1
- package/esm/testing/stubBrowserCommandContext.js +0 -12
- package/esm/testing/stubSuite.d.ts +0 -10
- package/esm/testing/stubSuite.d.ts.map +0 -1
- package/esm/testing/stubSuite.js +0 -27
- package/esm/testing/stubUserConfig.d.ts +0 -7
- package/esm/testing/stubUserConfig.d.ts.map +0 -1
- package/esm/testing/stubUserConfig.js +0 -4
- package/esm/testing.d.ts +0 -3
- package/esm/testing.d.ts.map +0 -1
- package/esm/testing.js +0 -2
- package/src/testing/stubBrowserCommandContext.ts +0 -16
- package/src/testing/stubUserConfig.ts +0 -6
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { m as ToMatchImageSnapshotOptions, n as ComparisonMethod } from "./types-DFb23VE1.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/client/expect/to_match_image_snapshot.types.d.ts
|
|
4
|
+
interface ImageSnapshotMatcher {
|
|
5
|
+
toMatchImageSnapshot<M extends ComparisonMethod>(options?: ToMatchImageSnapshotOptions<M> | undefined): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ImageSnapshotMatcher as t };
|
|
9
|
+
//# sourceMappingURL=to_match_image_snapshot.types-p-zilA_M.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to_match_image_snapshot.types-p-zilA_M.d.mts","names":[],"sources":["../src/client/expect/to_match_image_snapshot.types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,oBAAA;iCACe,4BAA4B,4BAA4B,iBAAiB;AADzG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/shared/trim_common_folder.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Trim off common folder such as `src` or `tests` from the test file path.
|
|
4
|
+
* This is used to generate the default snapshot sub-path.
|
|
5
|
+
*/
|
|
6
|
+
declare function trimCommonFolder(suiteName: string): string;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { trimCommonFolder as t };
|
|
9
|
+
//# sourceMappingURL=trim_common_folder-ModiubEJ.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trim_common_folder-ModiubEJ.d.mts","names":[],"sources":["../src/shared/trim_common_folder.ts"],"sourcesContent":[],"mappings":";;AAIA;;;iBAAgB,gBAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import pixelMatch from "pixelmatch";
|
|
2
|
+
import { Options as SsimDiffOptions } from "ssim.js";
|
|
3
|
+
|
|
4
|
+
//#region src/client/snapshot_meta.d.ts
|
|
5
|
+
type SnapshotMeta<M extends ComparisonMethod> = ToMatchImageSnapshotOptions<M> & ImageSnapshotSubjectOptions & {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to enable the snapshot.
|
|
8
|
+
*
|
|
9
|
+
* Default: `true`
|
|
10
|
+
*/
|
|
11
|
+
enable?: boolean | undefined;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/shared/constants.d.ts
|
|
16
|
+
declare const NAME = "vis";
|
|
17
|
+
declare const SNAPSHOT_ROOT_DIR = "__vis__";
|
|
18
|
+
declare const BASELINE_DIR = "__baselines__";
|
|
19
|
+
declare const RESULT_DIR = "__results__";
|
|
20
|
+
declare const DIFF_DIR = "__diffs__";
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/shared/types.d.ts
|
|
23
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
24
|
+
interface ImageSnapshotTimeoutOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Timeout for taking the snapshot.
|
|
27
|
+
*
|
|
28
|
+
* Default: 30000 ms (30 seconds)
|
|
29
|
+
*/
|
|
30
|
+
timeout?: number | undefined;
|
|
31
|
+
}
|
|
32
|
+
interface ImageSnapshotKeyOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Customize the `snapshotKey` of the snapshot.
|
|
35
|
+
*/
|
|
36
|
+
snapshotKey?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
type ComparisonMethod = 'pixel' | 'ssim';
|
|
39
|
+
type FailureThresholdOptions = {
|
|
40
|
+
/**
|
|
41
|
+
* Failure threshold should measure in `pixel` or `percent`.
|
|
42
|
+
*
|
|
43
|
+
* Default is `pixel`.
|
|
44
|
+
*/
|
|
45
|
+
failureThresholdType?: 'pixel' | 'percent' | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Failure tolerance threshold.
|
|
48
|
+
*
|
|
49
|
+
* If `failureThresholdType` is `pixel`, the value is the number of pixels that are allowed to be different.
|
|
50
|
+
* If `failureThresholdType` is `percent`, the value is the percentage of pixels that are allowed to be different.
|
|
51
|
+
*
|
|
52
|
+
* Default is `0`.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* // Allow 10 pixels to be different
|
|
57
|
+
* failureThresholdType: 'pixel'
|
|
58
|
+
* failureThreshold: 10
|
|
59
|
+
*
|
|
60
|
+
* // Allow 10% of pixels to be different
|
|
61
|
+
* failureThresholdType: 'percent'
|
|
62
|
+
* failureThreshold: 10
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
failureThreshold?: number | undefined;
|
|
66
|
+
};
|
|
67
|
+
type SsimComparisonOptions<M = 'ssim'> = {
|
|
68
|
+
comparisonMethod: M;
|
|
69
|
+
/**
|
|
70
|
+
* Custom options passed to 'ssim'
|
|
71
|
+
*/
|
|
72
|
+
diffOptions?: Partial<SsimDiffOptions> | undefined;
|
|
73
|
+
};
|
|
74
|
+
type PixelComparisonOptions<M = 'pixel'> = {
|
|
75
|
+
comparisonMethod?: M | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Custom options passed to 'pixelmatch'
|
|
78
|
+
*/
|
|
79
|
+
diffOptions?: PixelDiffOptions | undefined;
|
|
80
|
+
};
|
|
81
|
+
type PixelDiffOptions = Parameters<typeof pixelMatch>[5];
|
|
82
|
+
type ImageSnapshotCompareOptions<M extends ComparisonMethod = 'pixel'> = (M extends 'ssim' ? SsimComparisonOptions<M> : PixelComparisonOptions<M>) & FailureThresholdOptions;
|
|
83
|
+
type ImageSnapshotSubjectOptions = {
|
|
84
|
+
/**
|
|
85
|
+
* Specify the query of the subject element.
|
|
86
|
+
*
|
|
87
|
+
* If the test does not have an element with the specified query,
|
|
88
|
+
* the `body` element will be used.
|
|
89
|
+
*/
|
|
90
|
+
subject?: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
type ToMatchImageSnapshotOptions<M extends ComparisonMethod = 'pixel'> = ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & ImageSnapshotCompareOptions<M> & {
|
|
93
|
+
/**
|
|
94
|
+
* Expect the matcher to fail.
|
|
95
|
+
* If it passes, it will throw an error with details.
|
|
96
|
+
*/
|
|
97
|
+
expectToFail?: boolean | undefined;
|
|
98
|
+
};
|
|
99
|
+
interface PageImageSnapshotOptions {
|
|
100
|
+
fullPage?: boolean | undefined;
|
|
101
|
+
}
|
|
102
|
+
type ToMatchPageImageSnapshotOptions<M extends ComparisonMethod = 'pixel'> = ToMatchImageSnapshotOptions<M> & PageImageSnapshotOptions;
|
|
103
|
+
type SnapshotTestMeta = {
|
|
104
|
+
meta: {
|
|
105
|
+
[NAME]?: SnapshotMeta<ComparisonMethod>;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
//#endregion
|
|
109
|
+
export { DIFF_DIR as _, ImageSnapshotKeyOptions as a, SNAPSHOT_ROOT_DIR as b, PageImageSnapshotOptions as c, SnapshotTestMeta as d, SsimComparisonOptions as f, BASELINE_DIR as g, ToMatchPageImageSnapshotOptions as h, ImageSnapshotCompareOptions as i, PixelComparisonOptions as l, ToMatchImageSnapshotOptions as m, ComparisonMethod as n, ImageSnapshotSubjectOptions as o, SsimDiffOptions as p, FailureThresholdOptions as r, ImageSnapshotTimeoutOptions as s, Awaitable as t, PixelDiffOptions as u, NAME as v, SnapshotMeta as x, RESULT_DIR as y };
|
|
110
|
+
//# sourceMappingURL=types-DFb23VE1.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-DFb23VE1.d.mts","names":[],"sources":["../src/client/snapshot_meta.ts","../src/shared/constants.ts","../src/shared/types.ts"],"sourcesContent":[],"mappings":";;;;KAEY,uBAAuB,oBAAoB,4BAA4B,KAClF;;;AADD;;;EAAuD,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA;EACtD,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAA2B;;;cCHf,IAAA;cACA,iBAAA;cACA,YAAA;cACA,UAAA;ADDD,cCEC,QAAA,GDFW,WAAA;;;AAAZ,KEGA,SFHY,CAAA,CAAA,CAAA,GEGG,CFHH,GEGO,WFHP,CEGmB,CFHnB,CAAA;AAAW,UEKlB,2BAAA,CFLkB;EAAgD;;;;;;;ACFtE,UCgBI,uBAAA,CDhBA;EACJ;AACb;AACA;EACa,WAAQ,CAAA,EAAA,MAAA,GAAA,SAAA;;KCmBT,gBAAA;KAEA,uBAAA;EApBA;;;;;EAEK,oBAAA,CAAA,EAAA,OAA2B,GAAA,SAAA,GAAA,SAAA;EAS3B;AAOjB;AAEA;AA6BA;;;;;AAUA;AAQA;AAEA;;;;;;;;;EAKY,gBAAA,CAAA,EAAA,MAAA,GAAA,SAA2B;AASvC,CAAA;AAAkD,KAlCtC,qBAkCsC,CAAA,IAAA,MAAA,CAAA,GAAA;EAA8B,gBAAA,EAjC7D,CAiC6D;EAC/E;;;EAC2B,WAAA,CAAA,EA/Bb,OA+Ba,CA/BL,eA+BK,CAAA,GAAA,SAAA;AAQ5B,CAAA;AAIsD,KAtC1C,sBAsC0C,CAAA,IAAA,OAAA,CAAA,GAAA;EAA0D,gBAAA,CAAA,EArC5F,CAqC4F,GAAA,SAAA;EAA5B;;;EAGxE,WAAA,CAAA,EApCG,gBAoCa,GAAA,SAAA;CAEJ;AAAb,KAnCC,gBAAA,GAAmB,UAmCpB,CAAA,OAnCsC,UAmCtC,CAAA,CAAA,CAAA,CAAA;AAAR,KAjCS,2BAiCT,CAAA,UAjC+C,gBAiC/C,GAAA,OAAA,CAAA,GAAA,CAjC8E,CAiC9E,SAAA,MAAA,GAhCA,qBAgCA,CAhCsB,CAgCtB,CAAA,GA/BA,sBA+BA,CA/BuB,CA+BvB,CAAA,CAAA,GA9BF,uBA8BE;AAAI,KA5BK,2BAAA,GA4BL;;;;;;;;;KAnBK,sCAAsC,8BAA8B,8BAC/E,0BACA,4BAA4B;;;;;;;UAQZ,wBAAA;;;KAIL,0CAA0C,8BAA8B,4BAA4B,KAC/G;KAEW,gBAAA;;KAET,IAAA,IAAQ,aAAa"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { a as ImageSnapshotKeyOptions, n as ComparisonMethod, o as ImageSnapshotSubjectOptions, p as SsimDiffOptions, r as FailureThresholdOptions, s as ImageSnapshotTimeoutOptions, u as PixelDiffOptions } from "./types-DFb23VE1.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/config/types.d.ts
|
|
4
|
+
type VisOptions<M extends ComparisonMethod = 'pixel'> = (M extends 'ssim' ? {
|
|
5
|
+
comparisonMethod: M;
|
|
6
|
+
/**
|
|
7
|
+
* Custom options passed to 'ssim'
|
|
8
|
+
*/
|
|
9
|
+
diffOptions?: Partial<SsimDiffOptions> | undefined;
|
|
10
|
+
} : {
|
|
11
|
+
comparisonMethod?: M | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Custom options passed to 'pixelmatch'
|
|
14
|
+
*/
|
|
15
|
+
diffOptions?: PixelDiffOptions | undefined;
|
|
16
|
+
}) & FailureThresholdOptions & ImageSnapshotTimeoutOptions & ImageSnapshotKeyOptions & ImageSnapshotSubjectOptions & {
|
|
17
|
+
/**
|
|
18
|
+
* Loads the `test.setupFiles` of the specified preset.
|
|
19
|
+
*
|
|
20
|
+
* Note:
|
|
21
|
+
* - 'enable` is deprecated. Use `manual` for the same effect.
|
|
22
|
+
* - 'none` is deprecated. Use `custom` for the same effect.
|
|
23
|
+
*
|
|
24
|
+
* @default 'auto'
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
preset?: 'enable' | 'manual' | 'auto' | 'custom' | 'none' | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* The snapshot folder relative to the root of the project.
|
|
30
|
+
*
|
|
31
|
+
* Default: `{projectRoot}/__vis__/{platform}`
|
|
32
|
+
*/
|
|
33
|
+
snapshotRootDir?: string | ((context: {
|
|
34
|
+
ci: boolean;
|
|
35
|
+
browserName?: string | undefined;
|
|
36
|
+
providerName: string;
|
|
37
|
+
platform: string;
|
|
38
|
+
screenshotFailures?: boolean | undefined;
|
|
39
|
+
screenshotDirectory?: string | undefined;
|
|
40
|
+
}) => string) | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Customize the snapshot subpath.
|
|
43
|
+
*
|
|
44
|
+
* Typically, you place your test files either in a dedicated `tests` folder or in the `src` folder along with your source code.
|
|
45
|
+
* By default, the snapshot subpath is the test file path with that folder removed to reduces nesting of the snapshot folders.
|
|
46
|
+
*
|
|
47
|
+
* If you place your test files in multiple folders,
|
|
48
|
+
* such as in both `tests` and `src` folders,
|
|
49
|
+
* and they might have files with the same name and create conflicting snapshots,
|
|
50
|
+
* you can set this to customize the snapshot subpath.
|
|
51
|
+
*
|
|
52
|
+
* @param options - Options for customizing the snapshot subpath.
|
|
53
|
+
* @property subPath - The path of the test file to be used as the snapshot subpath.
|
|
54
|
+
* To retain the full path, simply return it.
|
|
55
|
+
* @returns The customized snapshot subpath.
|
|
56
|
+
*/
|
|
57
|
+
snapshotSubpath?: ((options: {
|
|
58
|
+
subpath: string;
|
|
59
|
+
}) => string) | undefined;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { VisOptions as t };
|
|
63
|
+
//# sourceMappingURL=types-Do1N7g4c.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-Do1N7g4c.d.mts","names":[],"sources":["../src/config/types.ts"],"sourcesContent":[],"mappings":";;;KAcY,qBAAqB,+BAA+B;EAApD,gBAAU,EAED,CAFC;EAAW;;;EAMR,WAAA,CAAA,EAAR,OAAQ,CAAA,eAAA,CAAA,GAAA,SAAA;CAAR,GAAA;EAGK,gBAAA,CAAA,EAAA,CAAA,GAAA,SAAA;EAIL;;;EAIhB,WAAA,CAAA,EAJgB,gBAIhB,GAAA,SAAA;CACA,CAAA,GAHA,uBAGA,GAFA,2BAEA,GADA,uBACA,GAAA,2BAAA,GAAA;EAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-plugin-vis",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Vitest visual testing plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"image-snapshot",
|
|
@@ -20,50 +20,51 @@
|
|
|
20
20
|
},
|
|
21
21
|
"type": "module",
|
|
22
22
|
"imports": {
|
|
23
|
-
"#vitest-plugin-vis/config": "./src/config.ts"
|
|
23
|
+
"#vitest-plugin-vis/config": "./src/config.ts",
|
|
24
|
+
"#vitest-plugin-vis/setup": "./src/setup.ts"
|
|
24
25
|
},
|
|
25
26
|
"exports": {
|
|
26
27
|
".": {
|
|
27
|
-
"types": "./
|
|
28
|
-
"default": "./
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
29
|
+
"default": "./dist/index.mjs"
|
|
29
30
|
},
|
|
30
31
|
"./config": {
|
|
31
|
-
"types": "./
|
|
32
|
-
"default": "./
|
|
32
|
+
"types": "./dist/config.d.mts",
|
|
33
|
+
"default": "./dist/config.mjs"
|
|
33
34
|
},
|
|
34
35
|
"./client-api": {
|
|
35
|
-
"types": "./
|
|
36
|
-
"default": "./
|
|
36
|
+
"types": "./dist/client-api.d.mts",
|
|
37
|
+
"default": "./dist/client-api.mjs"
|
|
37
38
|
},
|
|
38
39
|
"./presets/auto": {
|
|
39
|
-
"types": "./
|
|
40
|
-
"default": "./
|
|
40
|
+
"types": "./dist/presets/auto.d.mts",
|
|
41
|
+
"default": "./dist/presets/auto.mjs"
|
|
41
42
|
},
|
|
42
43
|
"./presets/enable": {
|
|
43
|
-
"types": "./
|
|
44
|
-
"default": "./
|
|
44
|
+
"types": "./dist/presets/enable.d.mts",
|
|
45
|
+
"default": "./dist/presets/enable.mjs"
|
|
45
46
|
},
|
|
46
47
|
"./presets/manual": {
|
|
47
|
-
"types": "./
|
|
48
|
-
"default": "./
|
|
48
|
+
"types": "./dist/presets/manual.d.mts",
|
|
49
|
+
"default": "./dist/presets/manual.mjs"
|
|
49
50
|
},
|
|
50
51
|
"./server-utils": {
|
|
51
|
-
"types": "./
|
|
52
|
-
"default": "./
|
|
52
|
+
"types": "./dist/server-utils.d.mts",
|
|
53
|
+
"default": "./dist/server-utils.mjs"
|
|
53
54
|
},
|
|
54
55
|
"./setup": {
|
|
55
|
-
"types": "./
|
|
56
|
-
"default": "./
|
|
56
|
+
"types": "./dist/setup.d.mts",
|
|
57
|
+
"default": "./dist/setup.mjs"
|
|
57
58
|
},
|
|
58
59
|
"./testing": {
|
|
59
|
-
"types": "./
|
|
60
|
-
"default": "./
|
|
60
|
+
"types": "./dist/testing.d.mts",
|
|
61
|
+
"default": "./dist/testing.mjs"
|
|
61
62
|
},
|
|
62
63
|
"./package.json": "./package.json"
|
|
63
64
|
},
|
|
64
|
-
"types": "./
|
|
65
|
+
"types": "./dist/index.d.mts",
|
|
65
66
|
"files": [
|
|
66
|
-
"
|
|
67
|
+
"dist",
|
|
67
68
|
"src",
|
|
68
69
|
"!**/*.{spec,test,unit,accept,integrate,system,perf,stress}.*"
|
|
69
70
|
],
|
|
@@ -80,44 +81,58 @@
|
|
|
80
81
|
"type-plus": "8.0.0-beta.7"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
|
-
"@repobuddy/storybook": "^2.
|
|
84
|
+
"@repobuddy/storybook": "^2.1.2",
|
|
84
85
|
"@repobuddy/typescript": "^2.1.0",
|
|
85
|
-
"@storybook-community/storybook-dark-mode": "^7.0.
|
|
86
|
-
"@storybook/addon-docs": "^10.
|
|
87
|
-
"@storybook/addon-vitest": "^
|
|
88
|
-
"@storybook/react-vite": "^
|
|
86
|
+
"@storybook-community/storybook-dark-mode": "^7.0.3",
|
|
87
|
+
"@storybook/addon-docs": "^10.1.2",
|
|
88
|
+
"@storybook/addon-vitest": "^10.1.2",
|
|
89
|
+
"@storybook/react-vite": "^10.1.2",
|
|
89
90
|
"@tailwindcss/vite": "^4.1.14",
|
|
90
91
|
"@types/is-ci": "^3.0.4",
|
|
91
92
|
"@types/pngjs": "^6.0.5",
|
|
92
93
|
"@types/react": "^19.2.2",
|
|
93
|
-
"@vitest/browser": "^
|
|
94
|
-
"@vitest/
|
|
95
|
-
"@vitest/
|
|
96
|
-
"@vitest/
|
|
94
|
+
"@vitest/browser": "^4.0.9",
|
|
95
|
+
"@vitest/browser-playwright": "^4.0.9",
|
|
96
|
+
"@vitest/browser-webdriverio": "^4.0.9",
|
|
97
|
+
"@vitest/coverage-istanbul": "^4.0.9",
|
|
98
|
+
"@vitest/coverage-v8": "^4.0.9",
|
|
99
|
+
"@vitest/expect": "^4.0.9",
|
|
100
|
+
"@vitest/ui": "4.0.9",
|
|
97
101
|
"cross-env": "^10.0.0",
|
|
98
102
|
"never-fail": "^1.1.4",
|
|
99
103
|
"npm-run-all2": "^8.0.0",
|
|
100
104
|
"react": "^19.0.0",
|
|
101
105
|
"react-dom": "^19.0.0",
|
|
102
|
-
"storybook": "^
|
|
103
|
-
"storybook-addon-tag-badges": "^3.0.
|
|
106
|
+
"storybook": "^10.1.2",
|
|
107
|
+
"storybook-addon-tag-badges": "^3.0.2",
|
|
104
108
|
"tailwindcss": "^4.1.14",
|
|
109
|
+
"tsdown": "^0.16.6",
|
|
105
110
|
"typescript": "^5.9.3",
|
|
106
111
|
"vite": "^7.1.12",
|
|
107
|
-
"vitest": "^
|
|
108
|
-
"vitest-browser-react": "^
|
|
112
|
+
"vitest": "^4.0.9",
|
|
113
|
+
"vitest-browser-react": "^2.0.2"
|
|
109
114
|
},
|
|
110
115
|
"peerDependencies": {
|
|
111
|
-
"@vitest/browser": "^
|
|
112
|
-
"vitest": "^
|
|
116
|
+
"@vitest/browser": "^4",
|
|
117
|
+
"@vitest/browser-playwright": "^4",
|
|
118
|
+
"@vitest/browser-webdriverio": "^4",
|
|
119
|
+
"vitest": "^4"
|
|
120
|
+
},
|
|
121
|
+
"peerDependenciesMeta": {
|
|
122
|
+
"@vitest/browser-playwright": {
|
|
123
|
+
"optional": true
|
|
124
|
+
},
|
|
125
|
+
"@vitest/browser-webdriverio": {
|
|
126
|
+
"optional": true
|
|
127
|
+
}
|
|
113
128
|
},
|
|
114
129
|
"publishConfig": {
|
|
115
130
|
"access": "public"
|
|
116
131
|
},
|
|
117
132
|
"scripts": {
|
|
118
|
-
"build": "
|
|
133
|
+
"build": "tsdown",
|
|
119
134
|
"build:watch": "tsc -b tsconfig.esm.json -w",
|
|
120
|
-
"clean": "rimraf coverage esm --glob *.tsbuildinfo vitest.*.timestamp*",
|
|
135
|
+
"clean": "rimraf coverage dist esm --glob *.tsbuildinfo vitest.*.timestamp*",
|
|
121
136
|
"clean:vis:local": "rimraf __vis__/local",
|
|
122
137
|
"cov": "cross-env COVERAGE=true vitest run --coverage",
|
|
123
138
|
"coverage": "cross-env COVERAGE=true vitest run --coverage",
|
|
@@ -127,6 +142,7 @@
|
|
|
127
142
|
"sb": "storybook dev -p 6007",
|
|
128
143
|
"t:node": "vitest --project=vpv:node",
|
|
129
144
|
"t:pw": "vitest run --project=\"vpv:pw (*)\"",
|
|
145
|
+
"t:t": "tsc --noEmit",
|
|
130
146
|
"t:wd": "vitest run --project=\"vpv:wd (*)\"",
|
|
131
147
|
"test": "vitest run",
|
|
132
148
|
"test:u": "vitest run -u",
|
package/readme.md
CHANGED
|
@@ -26,6 +26,7 @@ The [`vitest-plugin-vis`][vitest-plugin-vis] plugin can be used without customiz
|
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
// vitest.config.ts
|
|
29
|
+
import { playwright } from '@vitest/browser-playwright'
|
|
29
30
|
import { defineConfig } from 'vitest/config'
|
|
30
31
|
import { vis } from 'vitest-plugin-vis/config'
|
|
31
32
|
|
|
@@ -45,6 +46,14 @@ export default defineConfig({
|
|
|
45
46
|
instances: [
|
|
46
47
|
{ browser: 'chromium' }
|
|
47
48
|
]
|
|
49
|
+
},
|
|
50
|
+
// vitest v4
|
|
51
|
+
browser: {
|
|
52
|
+
enabled: true,
|
|
53
|
+
provider: playwright(),
|
|
54
|
+
instances: [
|
|
55
|
+
{ browser: 'chromium' }
|
|
56
|
+
]
|
|
48
57
|
}
|
|
49
58
|
}
|
|
50
59
|
})
|
|
@@ -166,7 +175,50 @@ By default, the plugin will trim the common folder such as `src` or `test` from
|
|
|
166
175
|
If you place your test files in multiple folders,
|
|
167
176
|
such as in both `tests` and `src` folders,
|
|
168
177
|
and they might have files with the same name and create conflicting snapshots,
|
|
169
|
-
you can customize
|
|
178
|
+
you can use `snapshotSubpath` to customize the snapshot sub-path to avoid conflicts.
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
// vitest.config.ts
|
|
182
|
+
import { storybookVis } from 'storybook-addon-vis/vitest-plugin'
|
|
183
|
+
import { defineConfig } from 'vitest/config'
|
|
184
|
+
|
|
185
|
+
export default defineConfig({
|
|
186
|
+
plugins: [
|
|
187
|
+
storybookVis({
|
|
188
|
+
// keep the folder structure
|
|
189
|
+
snapshotSubpath: (subpath) => subpath
|
|
190
|
+
})
|
|
191
|
+
],
|
|
192
|
+
// ...
|
|
193
|
+
})
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
With the above configuration, the snapshot folder structure will look like this:
|
|
197
|
+
|
|
198
|
+
```ini
|
|
199
|
+
v __vis__
|
|
200
|
+
> # ...
|
|
201
|
+
v local # snapshot generated on local machine
|
|
202
|
+
> __baselines__
|
|
203
|
+
v examples
|
|
204
|
+
v button.stories.tsx
|
|
205
|
+
snapshot-1.png
|
|
206
|
+
snapshot-2.png
|
|
207
|
+
v src
|
|
208
|
+
v button.stories.tsx
|
|
209
|
+
snapshot-1.png
|
|
210
|
+
snapshot-2.png
|
|
211
|
+
v tests
|
|
212
|
+
v button.stories.tsx
|
|
213
|
+
snapshot-1.png
|
|
214
|
+
snapshot-2.png
|
|
215
|
+
v examples
|
|
216
|
+
button.stories.tsx
|
|
217
|
+
v src
|
|
218
|
+
button.stories.tsx
|
|
219
|
+
v tests
|
|
220
|
+
button.stories.tsx
|
|
221
|
+
```
|
|
170
222
|
|
|
171
223
|
> `MyComponent/className/can-customize-className`: `snapshotId`
|
|
172
224
|
|
|
@@ -231,7 +283,7 @@ You can also customize the subject per test using the `setAutoSnapshotOptions` f
|
|
|
231
283
|
|
|
232
284
|
```ts
|
|
233
285
|
// some.test.ts
|
|
234
|
-
import { page } from '
|
|
286
|
+
import { page } from 'vitest/browser'
|
|
235
287
|
import { expect, it } from 'vitest'
|
|
236
288
|
import { render } from 'vitest-browser-react'
|
|
237
289
|
import { setAutoSnapshotOptions } from 'vitest-plugin-vis'
|
|
@@ -386,7 +438,7 @@ You can take snapshots manually:
|
|
|
386
438
|
```ts
|
|
387
439
|
// some.test.ts
|
|
388
440
|
import { render } from 'vitest-browser-react'
|
|
389
|
-
import { page } from '
|
|
441
|
+
import { page } from 'vitest/browser'
|
|
390
442
|
import { it } from 'vitest'
|
|
391
443
|
|
|
392
444
|
it('manual snapshot', async ({ expect }) => {
|
|
@@ -403,7 +455,7 @@ You can customize the snapshot comparison options per assertion:
|
|
|
403
455
|
```ts
|
|
404
456
|
// some.test.ts
|
|
405
457
|
import { render } from 'vitest-browser-react'
|
|
406
|
-
import { page } from '
|
|
458
|
+
import { page } from 'vitest/browser'
|
|
407
459
|
import { it } from 'vitest'
|
|
408
460
|
|
|
409
461
|
it('manual snapshot with options', async ({ expect }) => {
|
|
@@ -426,7 +478,7 @@ it('manual snapshot with options', async ({ expect }) => {
|
|
|
426
478
|
You can also take a full page snapshot:
|
|
427
479
|
|
|
428
480
|
```ts
|
|
429
|
-
import { page } from '
|
|
481
|
+
import { page } from 'vitest/browser'
|
|
430
482
|
import { it } from 'vitest'
|
|
431
483
|
|
|
432
484
|
it('full page snapshot', async () => {
|
|
@@ -439,7 +491,7 @@ it('full page snapshot', async () => {
|
|
|
439
491
|
While less common, you can also check if a snapshot exists:
|
|
440
492
|
|
|
441
493
|
```ts
|
|
442
|
-
import { page } from '
|
|
494
|
+
import { page } from 'vitest/browser'
|
|
443
495
|
import { it } from 'vitest'
|
|
444
496
|
|
|
445
497
|
it('Has Snapshot', async ({ expect }) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BrowserCommands } from '
|
|
1
|
+
import type { BrowserCommands } from 'vitest/browser'
|
|
2
2
|
import type { ImageSnapshotNextIndexCommand } from '../../commands.ts'
|
|
3
3
|
import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts'
|
|
4
4
|
import { assertSnapshotKeyWithoutDash } from '../../shared/asserts.ts'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BrowserCommands } from '
|
|
1
|
+
import type { BrowserCommands } from 'vitest/browser'
|
|
2
2
|
import type { ImageSnapshotNextIndexCommand } from '../../commands.ts'
|
|
3
3
|
import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts'
|
|
4
4
|
import { assertSnapshotKeyWithoutDash } from '../../shared/asserts.ts'
|
|
@@ -17,6 +17,21 @@ export type MetaTask =
|
|
|
17
17
|
/**
|
|
18
18
|
* Set the snapshot options for auto snapshot.
|
|
19
19
|
*
|
|
20
|
+
* You can use it in beforeAll, beforeEach, or individual test cases.
|
|
21
|
+
*
|
|
22
|
+
* @param meta - The snapshot options to set.
|
|
23
|
+
* You can pass a boolean to enable/disable the snapshot, or an object with the snapshot options.
|
|
24
|
+
* When passing an object, the `enable` property will be set to `true` by default unless you explicitly set it to `false`.
|
|
25
|
+
* @param meta.enable - Whether to enable the snapshot.
|
|
26
|
+
* @param meta.snapshotKey - The key to use for the snapshot.
|
|
27
|
+
* @param meta.comparisonMethod - The comparison method to use for the snapshot.
|
|
28
|
+
* @param meta.diffOptions - The diff options to use for the snapshot.
|
|
29
|
+
* @param meta.failureThreshold - The failure threshold to use for the snapshot.
|
|
30
|
+
* @param meta.failureThresholdType - The failure threshold type to use for the snapshot.
|
|
31
|
+
* @param meta.timeout - The timeout to use for the snapshot.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
*
|
|
20
35
|
* ```ts
|
|
21
36
|
* beforeAll(() => setAutoSnapshotOptions(...))
|
|
22
37
|
* beforeEach(() => setAutoSnapshotOptions(...))
|
|
@@ -26,7 +41,7 @@ export type MetaTask =
|
|
|
26
41
|
* })
|
|
27
42
|
* ```
|
|
28
43
|
*/
|
|
29
|
-
export function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: SnapshotMeta<M>
|
|
44
|
+
export function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: boolean | SnapshotMeta<M>): void {
|
|
30
45
|
if (typeof meta === 'object') {
|
|
31
46
|
assertSnapshotKeyWithoutDash(meta.snapshotKey)
|
|
32
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commands } from '
|
|
1
|
+
import { commands } from 'vitest/browser'
|
|
2
2
|
import type { AsyncExpectationResult } from '@vitest/expect'
|
|
3
3
|
import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'
|
|
4
4
|
import { matchImageSnapshotAction } from '../actions/match_image_snapshot_action.ts'
|
|
@@ -11,7 +11,7 @@ This method allows you to conditionally execute code based on whether a snapshot
|
|
|
11
11
|
## Basic Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { page } from '
|
|
14
|
+
import { page } from 'vitest/browser'
|
|
15
15
|
|
|
16
16
|
it('should check if snapshot exists', async ({ expect }) => {
|
|
17
17
|
const hasSnapshot = await page.hasImageSnapshot()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BrowserPage, commands } from '
|
|
1
|
+
import { type BrowserPage, commands } from 'vitest/browser'
|
|
2
2
|
import type { ImageSnapshotKeyOptions } from '../../shared/types.ts'
|
|
3
3
|
import { hasImageSnapshotAction } from '../actions/has_image_snapshot_action.ts'
|
|
4
4
|
import { ctx } from '../ctx.ts'
|
|
@@ -11,7 +11,7 @@ Unlike `expect().toMatchImageSnapshot()` which targets specific elements, `page.
|
|
|
11
11
|
## Basic Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { page } from '
|
|
14
|
+
import { page } from 'vitest/browser'
|
|
15
15
|
|
|
16
16
|
it('should take a page snapshot', async () => {
|
|
17
17
|
// Your test setup here
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { commands } from '
|
|
1
|
+
import { commands } from 'vitest/browser'
|
|
2
2
|
import type { ComparisonMethod, ToMatchPageImageSnapshotOptions } from '../../shared/types.ts'
|
|
3
3
|
import { matchPageImageSnapshotAction } from '../actions/match_page_image_snapshot_action.ts'
|
|
4
4
|
import { ctx } from '../ctx.ts'
|
|
@@ -8,6 +8,21 @@ import { shouldTakeSnapshot } from '../should_take_snapshot.ts'
|
|
|
8
8
|
import type { SnapshotMeta } from '../snapshot_meta.ts'
|
|
9
9
|
import { toTaskId } from '../task_id.ts'
|
|
10
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
|
+
}
|
|
25
|
+
|
|
11
26
|
/**
|
|
12
27
|
* Visual test configuration on the client side.
|
|
13
28
|
*/
|
|
@@ -40,20 +55,7 @@ export type VisClientConfigurator<GM extends Record<string, any> | unknown = unk
|
|
|
40
55
|
* })
|
|
41
56
|
* ```
|
|
42
57
|
*/
|
|
43
|
-
setup(options?:
|
|
44
|
-
auto?:
|
|
45
|
-
| boolean
|
|
46
|
-
| (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
|
|
47
|
-
options: SnapshotMeta<C> & M & GM,
|
|
48
|
-
) => Promise<boolean> | Promise<void> | boolean | void)
|
|
49
|
-
| Record<
|
|
50
|
-
string,
|
|
51
|
-
| boolean
|
|
52
|
-
| (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(
|
|
53
|
-
options: SnapshotMeta<C> & M & GM,
|
|
54
|
-
) => Promise<boolean> | Promise<void> | boolean | void)
|
|
55
|
-
>
|
|
56
|
-
}): void
|
|
58
|
+
setup(options?: SetupVisOptions<GM>): void
|
|
57
59
|
/**
|
|
58
60
|
* @deprecated Use `vis.setup()` instead.
|
|
59
61
|
*/
|