vitest-plugin-vis 3.5.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asserts--HSSlgPD.mjs +8 -0
- package/dist/asserts--HSSlgPD.mjs.map +1 -0
- package/dist/augment-C1tjdh5B.d.mts +33 -0
- package/dist/augment-C1tjdh5B.d.mts.map +1 -0
- package/dist/auto_snapshot_matcher-C0y6mAeS.mjs +381 -0
- package/dist/auto_snapshot_matcher-C0y6mAeS.mjs.map +1 -0
- package/dist/auto_snapshot_options-BMRtKmod.d.mts +45 -0
- package/dist/auto_snapshot_options-BMRtKmod.d.mts.map +1 -0
- package/dist/auto_snapshot_options-DUOTpF2N.mjs +88 -0
- package/dist/auto_snapshot_options-DUOTpF2N.mjs.map +1 -0
- package/dist/base64-CHSENEAO.mjs +8 -0
- package/dist/base64-CHSENEAO.mjs.map +1 -0
- package/dist/client-api.d.mts +44 -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/commands.types-BVhcnnHw.d.mts +51 -0
- package/dist/commands.types-BVhcnnHw.d.mts.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-DCytWz48.mjs +124 -0
- package/dist/setup-DCytWz48.mjs.map +1 -0
- package/dist/setup.d.mts +106 -0
- package/dist/setup.d.mts.map +1 -0
- package/dist/setup.mjs +8 -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/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--tTmHoRA.d.mts +9 -0
- package/dist/to_match_image_snapshot.types--tTmHoRA.d.mts.map +1 -0
- package/dist/trim_common_folder-DBThLerp.d.mts +9 -0
- package/dist/trim_common_folder-DBThLerp.d.mts.map +1 -0
- package/dist/types-CEmjj-A9.d.mts +144 -0
- package/dist/types-CEmjj-A9.d.mts.map +1 -0
- package/dist/types-DJYCbyT8.d.mts +63 -0
- package/dist/types-DJYCbyT8.d.mts.map +1 -0
- package/package.json +55 -39
- package/readme.md +58 -6
- 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 +7 -5
- package/src/client/actions/match_page_image_snapshot_action.ts +6 -4
- 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_browser_context_proxy.ts → external/vitest/vitest_browser_context_proxy.ts} +3 -3
- 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/extend.ts +1 -1
- package/src/client/page/has_image_snapshot.mdx +1 -1
- package/src/client/page/has_image_snapshot.ts +4 -4
- package/src/client/page/to_match_image_snapshot.mdx +1 -1
- 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} +1 -1
- package/src/client/{compare_image_snapshot.ts → snapshot/compare_image_snapshot.ts} +8 -9
- 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 +68 -0
- package/src/client/{ctx.ts → task/_ctx.ts} +1 -3
- package/src/client/{auto_snapshot_options.ts → task/auto_snapshot_options.ts} +20 -5
- package/src/client/{snapshot_meta.ts → task/snapshot_meta.ts} +6 -1
- package/src/client-api.ts +3 -2
- package/src/config/vis.ts +4 -4
- package/src/index.ts +1 -1
- 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 +9 -7
- package/src/server/commands/has_image_snapshot.ts +3 -6
- package/src/server/commands/image_snapshot_next_index.ts +3 -9
- package/src/server/commands/load_image_snapshot_results.ts +3 -23
- package/src/server/commands/prepare_image_snapshot_comparison.ts +4 -50
- package/src/server/commands/prepare_page_image_snapshot_comparison.ts +3 -45
- package/src/server/commands/setup_vis_suite.ts +3 -27
- 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 +8 -8
- package/src/server/vis_server_context.types.ts +31 -26
- package/src/{client/setup → setup}/create_vis.ts +23 -78
- package/src/setup/readme.md +5 -0
- package/src/{client/setup → setup}/vis.ts +1 -1
- package/src/setup.ts +2 -2
- package/src/shared/commands.types.ts +71 -0
- package/src/shared/types.ts +55 -1
- 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/client/image_snapshot_options.ts +0 -6
- package/src/client/setup/vis.ctx.ts +0 -33
- package/src/client/should_take_snapshot.ts +0 -5
- package/src/server/commands/types.ts +0 -9
- package/src/testing/stubBrowserCommandContext.ts +0 -16
- package/src/testing/stubUserConfig.ts +0 -6
- /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/{auto_snapshot_options.mdx → task/auto_snapshot_options.mdx} +0 -0
- /package/src/client/{task_id.ts → task/task_id.ts} +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/shared/base64.ts
|
|
2
|
+
function isBase64String(value) {
|
|
3
|
+
return typeof value === "string" && /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test(value);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isBase64String as t };
|
|
8
|
+
//# sourceMappingURL=base64-CHSENEAO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64-CHSENEAO.mjs","names":[],"sources":["../src/shared/base64.ts"],"sourcesContent":["export function isBase64String(value: unknown): value is string {\n\treturn typeof value === 'string' && /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test(value)\n}\n"],"mappings":";AAAA,SAAgB,eAAe,OAAiC;AAC/D,QAAO,OAAO,UAAU,YAAY,mEAAmE,KAAK,MAAM"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { C as SNAPSHOT_ROOT_DIR, S as RESULT_DIR, _ as ToMatchImageSnapshotOptions, a as ImageSnapshotComparisonInfo, b as DIFF_DIR, c as ImageSnapshotTimeoutOptions, d as PixelComparisonOptions, f as PixelDiffOptions, g as SsimDiffOptions, h as SsimComparisonOptions, i as ImageSnapshotCompareOptions, l as MatchImageSnapshotOptions, m as SnapshotTestMeta, n as ComparisonMethod, o as ImageSnapshotKeyOptions, p as SetupVisOptions, r as FailureThresholdOptions, s as ImageSnapshotSubjectOptions, t as Awaitable, u as PageImageSnapshotOptions, v as ToMatchPageImageSnapshotOptions, w as SnapshotMeta, x as NAME, y as BASELINE_DIR } from "./types-CEmjj-A9.mjs";
|
|
2
|
+
import "./types-DJYCbyT8.mjs";
|
|
3
|
+
import { a as PrepareImageSnapshotComparisonCommand, i as LoadImageSnapshotResultsCommand, n as ImageSnapshotNextIndexCommand, o as PreparePageImageSnapshotComparisonCommand, r as ImageSnapshotResult, s as SetupVisSuiteCommand, t as HasImageSnapshotCommand } from "./commands.types-BVhcnnHw.mjs";
|
|
4
|
+
import { t as ImageSnapshotMatcher } from "./to_match_image_snapshot.types--tTmHoRA.mjs";
|
|
5
|
+
import { n as setAutoSnapshotOptions, t as MetaTask } from "./auto_snapshot_options-BMRtKmod.mjs";
|
|
6
|
+
import { BrowserCommands } from "vitest/browser";
|
|
7
|
+
import { SyncExpectationResult } from "@vitest/expect";
|
|
8
|
+
|
|
9
|
+
//#region src/server/commands/augment.d.ts
|
|
10
|
+
declare module 'vitest/browser' {
|
|
11
|
+
interface BrowserCommands extends SetupVisSuiteCommand, ImageSnapshotNextIndexCommand, HasImageSnapshotCommand, PreparePageImageSnapshotComparisonCommand, PrepareImageSnapshotComparisonCommand, LoadImageSnapshotResultsCommand {}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=augment.d.ts.map
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/client/actions/has_image_snapshot_action.d.ts
|
|
16
|
+
declare function hasImageSnapshotAction(commands: ImageSnapshotNextIndexCommand & HasImageSnapshotCommand, taskId: string, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/client/actions/load_image_snapshot_results_action.d.ts
|
|
19
|
+
declare function loadImageSnapshotResultsAction(commands: LoadImageSnapshotResultsCommand, taskId: string): Promise<ImageSnapshotResult[]>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/client/actions/match_image_snapshot_action.d.ts
|
|
22
|
+
declare function matchImageSnapshotAction(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, subject: any, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/client/actions/match_page_image_snapshot_action.d.ts
|
|
25
|
+
declare function matchPageImageSnapshotAction(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/client/expect/expectation_result.d.ts
|
|
28
|
+
declare const success: SyncExpectationResult;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/client/suite/auto_snapshot_matcher.d.ts
|
|
31
|
+
declare function autoSnapshotMatcher<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand, expect: any): {
|
|
32
|
+
setup(): Promise<void>;
|
|
33
|
+
createMatcher<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): () => Promise<void>;
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/client/task/task_id.d.ts
|
|
37
|
+
type Task = {
|
|
38
|
+
name: string;
|
|
39
|
+
suite?: Task | undefined;
|
|
40
|
+
};
|
|
41
|
+
declare function toTaskId(task: Task): string;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { Awaitable, BASELINE_DIR, ComparisonMethod, DIFF_DIR, FailureThresholdOptions, ImageSnapshotCompareOptions, ImageSnapshotComparisonInfo, ImageSnapshotKeyOptions, ImageSnapshotMatcher, ImageSnapshotSubjectOptions, ImageSnapshotTimeoutOptions, MatchImageSnapshotOptions, type MetaTask, NAME, PageImageSnapshotOptions, PixelComparisonOptions, PixelDiffOptions, RESULT_DIR, SNAPSHOT_ROOT_DIR, SetupVisOptions, SnapshotTestMeta, SsimComparisonOptions, SsimDiffOptions, ToMatchImageSnapshotOptions, ToMatchPageImageSnapshotOptions, autoSnapshotMatcher, hasImageSnapshotAction, loadImageSnapshotResultsAction, matchImageSnapshotAction, matchPageImageSnapshotAction, setAutoSnapshotOptions, success, toTaskId };
|
|
44
|
+
//# sourceMappingURL=client-api.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-api.d.mts","names":[],"sources":["../src/server/commands/augment.ts","../src/client/actions/has_image_snapshot_action.ts","../src/client/actions/load_image_snapshot_results_action.ts","../src/client/actions/match_image_snapshot_action.ts","../src/client/actions/match_page_image_snapshot_action.ts","../src/client/expect/expectation_result.ts","../src/client/suite/auto_snapshot_matcher.ts","../src/client/task/task_id.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;oCAWU,sBACP,+BACA,yBACA,2CACA,uCACA;;;;;iBCba,sBAAA,WACL,gCAAgC,mDAEhC,sCAAmC;;;iBCJ9B,8BAAA,WAAyC,kDAA+C,QAAhB,mBAAA;;;iBCSlE,wBAAA,WACX,kBAAkB,wCAAwC,uEAG1D,mCAAgC;;;iBCNrB,4BAAA,WACX,kBAAkB,wCAAwC,yDAE1D,mCAAgC;;;cCV9B,SAAS;;;iBCON,+BAA+B,mDACpC;;0BASe,4BAA4B,iDAC3C,oCAEc,aAAa,KAAK,IAAI,OAAO,mBAAmB,yCACrE;;;;KCvBC,IAAA;;UAEI;;iBAGO,QAAA,OAAe"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./asserts--HSSlgPD.mjs";
|
|
2
|
+
import { a as SNAPSHOT_ROOT_DIR, i as RESULT_DIR, n as DIFF_DIR, r as NAME, t as BASELINE_DIR } from "./constants-CTBaz8Ml.mjs";
|
|
3
|
+
import { n as setAutoSnapshotOptions } from "./auto_snapshot_options-DUOTpF2N.mjs";
|
|
4
|
+
import "./base64-CHSENEAO.mjs";
|
|
5
|
+
import { a as matchImageSnapshotAction, i as matchPageImageSnapshotAction, n as toTaskId, o as hasImageSnapshotAction, r as success, t as autoSnapshotMatcher } from "./auto_snapshot_matcher-C0y6mAeS.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/client/actions/load_image_snapshot_results_action.ts
|
|
8
|
+
function loadImageSnapshotResultsAction(commands, taskId) {
|
|
9
|
+
return commands.loadImageSnapshotResults(taskId);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { BASELINE_DIR, DIFF_DIR, NAME, RESULT_DIR, SNAPSHOT_ROOT_DIR, autoSnapshotMatcher, hasImageSnapshotAction, loadImageSnapshotResultsAction, matchImageSnapshotAction, matchPageImageSnapshotAction, setAutoSnapshotOptions, success, toTaskId };
|
|
14
|
+
//# sourceMappingURL=client-api.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-api.mjs","names":[],"sources":["../src/client/actions/load_image_snapshot_results_action.ts"],"sourcesContent":["import type { LoadImageSnapshotResultsCommand } from '../../shared/commands.types.ts'\n\nexport function loadImageSnapshotResultsAction(commands: LoadImageSnapshotResultsCommand, taskId: string) {\n\treturn commands.loadImageSnapshotResults(taskId)\n}\n"],"mappings":";;;;;;;AAEA,SAAgB,+BAA+B,UAA2C,QAAgB;AACzG,QAAO,SAAS,yBAAyB,OAAO"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { a as ImageSnapshotComparisonInfo, l as MatchImageSnapshotOptions } from "./types-CEmjj-A9.mjs";
|
|
2
|
+
import { t as VisOptions } from "./types-DJYCbyT8.mjs";
|
|
3
|
+
import { Pick } from "type-plus";
|
|
4
|
+
|
|
5
|
+
//#region src/shared/commands.types.d.ts
|
|
6
|
+
interface PrepareImageSnapshotComparisonCommand {
|
|
7
|
+
prepareImageSnapshotComparison: (taskId: string, subject: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo | undefined>;
|
|
8
|
+
}
|
|
9
|
+
interface PreparePageImageSnapshotComparisonCommand {
|
|
10
|
+
preparePageImageSnapshotComparison: (taskId: string, options?: MatchImageSnapshotOptions | undefined) => Promise<ImageSnapshotComparisonInfo | undefined>;
|
|
11
|
+
}
|
|
12
|
+
interface SetupVisSuiteCommand {
|
|
13
|
+
/**
|
|
14
|
+
* Sets up the visual testing suite by cleaning up previous snapshot and diff output directories.
|
|
15
|
+
* When this command is run for the first time,
|
|
16
|
+
* it will remove the results and diffs directory of all suites.
|
|
17
|
+
*
|
|
18
|
+
* In subsequent runs, it will only remove the results and diffs directory of the current suite.
|
|
19
|
+
*/
|
|
20
|
+
setupVisSuite: () => Promise<Pick<VisOptions, 'comparisonMethod' | 'diffOptions' | 'failureThreshold' | 'failureThresholdType' | 'snapshotKey' | 'subject' | 'timeout'>>;
|
|
21
|
+
}
|
|
22
|
+
interface LoadImageSnapshotResultsCommand {
|
|
23
|
+
loadImageSnapshotResults(taskId: string): Promise<ImageSnapshotResult[]>;
|
|
24
|
+
}
|
|
25
|
+
interface ImageSnapshotResult {
|
|
26
|
+
filename: string;
|
|
27
|
+
/**
|
|
28
|
+
* The base64 encoded image of the baseline snapshot.
|
|
29
|
+
*/
|
|
30
|
+
baseline?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The base64 encoded image of the result snapshot.
|
|
33
|
+
*/
|
|
34
|
+
result?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* The base64 encoded image of the diff snapshot.
|
|
37
|
+
*/
|
|
38
|
+
diff?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
interface HasImageSnapshotCommand {
|
|
41
|
+
hasImageSnapshot(taskId: string, snapshotKey: string | undefined): Promise<boolean>;
|
|
42
|
+
}
|
|
43
|
+
interface ImageSnapshotNextIndexCommand {
|
|
44
|
+
/**
|
|
45
|
+
* Get the index of the snapshot image to be created.
|
|
46
|
+
*/
|
|
47
|
+
imageSnapshotNextIndex(taskId: string): Promise<number>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { PrepareImageSnapshotComparisonCommand as a, LoadImageSnapshotResultsCommand as i, ImageSnapshotNextIndexCommand as n, PreparePageImageSnapshotComparisonCommand as o, ImageSnapshotResult as r, SetupVisSuiteCommand as s, HasImageSnapshotCommand as t };
|
|
51
|
+
//# sourceMappingURL=commands.types-BVhcnnHw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.types-BVhcnnHw.d.mts","names":[],"sources":["../src/shared/commands.types.ts"],"sourcesContent":[],"mappings":";;;;;UAIiB,qCAAA;8EAIL,0CACN,QAAQ;AALd;AAIY,UAIK,yCAAA,CAJL;EACE,kCAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAMF,yBANE,GAAA,SAAA,EAAA,GAOR,OAPQ,CAOA,2BAPA,GAAA,SAAA,CAAA;;AAAD,UAUI,oBAAA,CAVJ;EAGI;;;;;AAOjB;;EASE,aAAA,EAAA,GAAA,GADoB,OACpB,CAAA,IAAA,CACC,UADD,EAAA,kBAAA,GAAA,aAAA,GAAA,kBAAA,GAAA,sBAAA,GAAA,aAAA,GAAA,SAAA,GAAA,SAAA,CAAA,CAAA;;AAD2B,UAcZ,+BAAA,CAdY;EAcZ,wBAAA,CAAA,MAAA,EAAA,MAA+B,CAAA,EACL,OAAQ,CAAA,mBAAR,EAAA,CAAA;AAG3C;AAgBiB,UAhBA,mBAAA,CAgBuB;EAIvB,QAAA,EAAA,MAAA;;;;;;;;;;;;;;UAJA,uBAAA;qEACmD;;UAGnD,6BAAA;;;;0CAIwB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { d as PixelComparisonOptions, f as PixelDiffOptions, g as SsimDiffOptions, h as SsimComparisonOptions, n as ComparisonMethod } from "./types-CEmjj-A9.mjs";
|
|
2
|
+
import { t as VisOptions } from "./types-DJYCbyT8.mjs";
|
|
3
|
+
import { t as trimCommonFolder } from "./trim_common_folder-DBThLerp.mjs";
|
|
4
|
+
import * as vite0 from "vite";
|
|
5
|
+
|
|
6
|
+
//#region src/config/vis.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a Vite plugin for visual testing.
|
|
10
|
+
*
|
|
11
|
+
* If options are not provided, the plugin will use the default options,
|
|
12
|
+
* which enables the `auto` preset.
|
|
13
|
+
*/
|
|
14
|
+
declare function vis<M extends ComparisonMethod = 'pixel'>(options?: VisOptions<M>): {
|
|
15
|
+
name: string;
|
|
16
|
+
config(this: unknown, userConfig: vite0.UserConfig): {
|
|
17
|
+
test: {
|
|
18
|
+
browser: {
|
|
19
|
+
name: undefined;
|
|
20
|
+
commands: any;
|
|
21
|
+
};
|
|
22
|
+
setupFiles: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { ComparisonMethod, PixelComparisonOptions, PixelDiffOptions, SsimComparisonOptions, SsimDiffOptions, VisOptions, trimCommonFolder, vis };
|
|
28
|
+
//# sourceMappingURL=config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config/vis.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAaA;;AAA8E,iBAA9D,GAA8D,CAAA,UAAhD,gBAAgD,GAAA,OAAA,CAAA,CAAA,OAAA,CAAA,EAAX,UAAW,CAAA,CAAA,CAAA,CAAA,EAAA;EAAX,IAAA,EAAA,MAAA;EAAU,MAGvD,CAAA,IAAA,EAAA,OAAA,EAAA,UAAA,EAHuD,KAAA,CAGvD,UAAA,CAAA,EAAA;IAAA,IAAA,EAAA"}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { t as assertSnapshotKeyWithoutDash } from "./asserts--HSSlgPD.mjs";
|
|
2
|
+
import { i as RESULT_DIR, n as DIFF_DIR, r as NAME, t as BASELINE_DIR } from "./constants-CTBaz8Ml.mjs";
|
|
3
|
+
import { i as trimCommonFolder, n as getSnapshotSubpath, r as resolveSnapshotRootDir } from "./snapshot_path-7GliOSH_.mjs";
|
|
4
|
+
import { t as isBase64String } from "./base64-CHSENEAO.mjs";
|
|
5
|
+
import { basename, dirname, join, relative, resolve } from "pathe";
|
|
6
|
+
import { pick } from "type-plus";
|
|
7
|
+
import { glob } from "glob";
|
|
8
|
+
import { mkdirp } from "mkdirp";
|
|
9
|
+
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
10
|
+
import ci from "is-ci";
|
|
11
|
+
import { rimraf } from "rimraf";
|
|
12
|
+
|
|
13
|
+
//#region src/server/externals/file.ts
|
|
14
|
+
const file = {
|
|
15
|
+
existFile(filePath) {
|
|
16
|
+
return stat(filePath).then((s) => s.isFile()).catch(() => false);
|
|
17
|
+
},
|
|
18
|
+
glob(pattern, options) {
|
|
19
|
+
return glob(pattern, options);
|
|
20
|
+
},
|
|
21
|
+
mkdirp,
|
|
22
|
+
async tryReadFile(filePath) {
|
|
23
|
+
if (!filePath) return void 0;
|
|
24
|
+
return readFile(filePath).catch(() => void 0);
|
|
25
|
+
},
|
|
26
|
+
writeFile
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/server/project.ts
|
|
31
|
+
function getProjectName(context) {
|
|
32
|
+
const { runner } = context.project;
|
|
33
|
+
const name = runner.config.name;
|
|
34
|
+
if (typeof name === "string") return name;
|
|
35
|
+
}
|
|
36
|
+
function getProjectRoot(context) {
|
|
37
|
+
return context.project.config.root;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/server/vis_options.ts
|
|
42
|
+
const DEFAULT_PROJECT_NAME = "__default";
|
|
43
|
+
const visOptions = {};
|
|
44
|
+
function setVisOption(userConfig, options) {
|
|
45
|
+
assertSnapshotKeyWithoutDash(options?.snapshotKey);
|
|
46
|
+
const name = userConfig.test?.name;
|
|
47
|
+
const id = typeof name === "string" ? name : typeof name === "object" ? name?.label : DEFAULT_PROJECT_NAME;
|
|
48
|
+
visOptions[id] = options;
|
|
49
|
+
}
|
|
50
|
+
function getVisOption(context) {
|
|
51
|
+
return visOptions[getProjectName(context) ?? DEFAULT_PROJECT_NAME] ?? {};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/server/vis_server_context.deps.ts
|
|
56
|
+
/* v8 ignore start */
|
|
57
|
+
const deps = {
|
|
58
|
+
rimraf,
|
|
59
|
+
getSnapshotPlatform() {
|
|
60
|
+
return ci ? process.platform : "local";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/* v8 ignore end */
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/server/suite.ts
|
|
67
|
+
const suites = {};
|
|
68
|
+
/**
|
|
69
|
+
* Setup suite is called on each test file's beforeAll hook.
|
|
70
|
+
* Test files include vitest test files and storybook story files.
|
|
71
|
+
* It needs to make sure there is no race condition between the test files.
|
|
72
|
+
*/
|
|
73
|
+
async function setupSuite(browserContext) {
|
|
74
|
+
const suiteId = getSuiteId(browserContext);
|
|
75
|
+
const visOptions$1 = getVisOption(browserContext);
|
|
76
|
+
if (!suites[suiteId]) suites[suiteId] = createSuite(browserContext, visOptions$1);
|
|
77
|
+
const suite = await suites[suiteId];
|
|
78
|
+
const { taskSubpath, baselineDir, diffDir, resultDir, tasks } = createModule(suite, browserContext.testPath, visOptions$1);
|
|
79
|
+
suite.modules[taskSubpath] = {
|
|
80
|
+
baselineDir,
|
|
81
|
+
diffDir,
|
|
82
|
+
resultDir,
|
|
83
|
+
tasks
|
|
84
|
+
};
|
|
85
|
+
await Promise.allSettled([deps.rimraf(diffDir), deps.rimraf(resultDir)]);
|
|
86
|
+
return {
|
|
87
|
+
comparisonMethod: visOptions$1.comparisonMethod,
|
|
88
|
+
diffOptions: visOptions$1.diffOptions,
|
|
89
|
+
failureThreshold: visOptions$1.failureThreshold,
|
|
90
|
+
failureThresholdType: visOptions$1.failureThresholdType,
|
|
91
|
+
snapshotKey: visOptions$1.snapshotKey,
|
|
92
|
+
subject: visOptions$1.subject,
|
|
93
|
+
timeout: visOptions$1.timeout
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Suite ID also contains the project name to make it unique
|
|
98
|
+
* across different projects.
|
|
99
|
+
*/
|
|
100
|
+
function getSuiteId(context) {
|
|
101
|
+
return `${getProjectName(context)}/${context.project.config.name}`;
|
|
102
|
+
}
|
|
103
|
+
async function createSuite(browserContext, visOptions$1) {
|
|
104
|
+
const snapshotRootDir = resolveSnapshotRootDir(browserContext, visOptions$1);
|
|
105
|
+
const projectRoot = getProjectRoot(browserContext);
|
|
106
|
+
const state = {
|
|
107
|
+
projectRoot,
|
|
108
|
+
testTimeout: browserContext.project.config.testTimeout,
|
|
109
|
+
hookTimeout: browserContext.project.config.hookTimeout,
|
|
110
|
+
snapshotRootDir,
|
|
111
|
+
snapshotBaselineDir: join(snapshotRootDir, BASELINE_DIR),
|
|
112
|
+
snapshotResultDir: join(snapshotRootDir, RESULT_DIR),
|
|
113
|
+
snapshotDiffDir: join(snapshotRootDir, DIFF_DIR),
|
|
114
|
+
snapshotRootPath: join(projectRoot, snapshotRootDir),
|
|
115
|
+
subject: visOptions$1.subject,
|
|
116
|
+
modules: {}
|
|
117
|
+
};
|
|
118
|
+
await Promise.allSettled([deps.rimraf(join(state.snapshotDiffDir)), deps.rimraf(join(state.snapshotResultDir))]);
|
|
119
|
+
return state;
|
|
120
|
+
}
|
|
121
|
+
function createModule(state, testPath, options) {
|
|
122
|
+
const taskSubpath = getTaskSubpath(state, testPath, options);
|
|
123
|
+
return {
|
|
124
|
+
taskSubpath,
|
|
125
|
+
baselineDir: join(state.snapshotBaselineDir, taskSubpath),
|
|
126
|
+
resultDir: join(state.snapshotResultDir, taskSubpath),
|
|
127
|
+
diffDir: join(state.snapshotDiffDir, taskSubpath),
|
|
128
|
+
tasks: {}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function getTaskSubpath(state, testPath, options) {
|
|
132
|
+
return getSnapshotSubpath(relative(state.projectRoot, testPath), options);
|
|
133
|
+
}
|
|
134
|
+
function getSuite(context) {
|
|
135
|
+
return suites[getSuiteId(context)];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/server/vis_server_context.logic.ts
|
|
140
|
+
function createVisServerContext() {
|
|
141
|
+
const context = {
|
|
142
|
+
async getSnapshotResults(browserContext, taskId) {
|
|
143
|
+
const suiteInfo = await context.getSuiteInfo(browserContext, taskId);
|
|
144
|
+
const baselines = await file.glob(join(suiteInfo.projectRoot, suiteInfo.baselineDir, `${suiteInfo.taskId}-*.png`));
|
|
145
|
+
const results = await file.glob(join(suiteInfo.projectRoot, suiteInfo.resultDir, `${suiteInfo.taskId}-*.png`));
|
|
146
|
+
const diffs = await file.glob(join(suiteInfo.projectRoot, suiteInfo.diffDir, `${suiteInfo.taskId}-*.png`));
|
|
147
|
+
const r = [];
|
|
148
|
+
await Promise.all(baselines.map(async (baselinePath) => {
|
|
149
|
+
const filename = basename(baselinePath);
|
|
150
|
+
const resultPath = results.find((r$1) => r$1.endsWith(filename));
|
|
151
|
+
const diffPath = diffs.find((d) => d.endsWith(filename));
|
|
152
|
+
const baselineBuffer = await file.tryReadFile(baselinePath);
|
|
153
|
+
const resultBuffer = await file.tryReadFile(resultPath);
|
|
154
|
+
const diffBuffer = await file.tryReadFile(diffPath);
|
|
155
|
+
r.push({
|
|
156
|
+
filename,
|
|
157
|
+
baseline: baselineBuffer?.toString("base64"),
|
|
158
|
+
result: resultBuffer?.toString("base64"),
|
|
159
|
+
diff: diffBuffer?.toString("base64")
|
|
160
|
+
});
|
|
161
|
+
}));
|
|
162
|
+
return r;
|
|
163
|
+
},
|
|
164
|
+
async getSnapshotInfo(browserContext, taskId, options) {
|
|
165
|
+
const suiteInfo = await context.getSuiteInfo(browserContext, taskId);
|
|
166
|
+
const snapshotFilename = context.getSnapshotFilename(browserContext, suiteInfo, options?.snapshotKey);
|
|
167
|
+
const { baselineDir, resultDir, diffDir, task } = suiteInfo;
|
|
168
|
+
task.count = task.count + 1;
|
|
169
|
+
const baselinePath = join(baselineDir, snapshotFilename);
|
|
170
|
+
const resultPath = join(resultDir, snapshotFilename);
|
|
171
|
+
const diffPath = join(diffDir, snapshotFilename);
|
|
172
|
+
return {
|
|
173
|
+
...pick(getVisOption(browserContext), "comparisonMethod", "diffOptions", "failureThreshold", "failureThresholdType", "timeout"),
|
|
174
|
+
baselinePath,
|
|
175
|
+
resultPath,
|
|
176
|
+
diffPath
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
async getTaskCount(browserContext, taskId) {
|
|
180
|
+
return (await context.getSuiteInfo(browserContext, taskId)).task.count;
|
|
181
|
+
},
|
|
182
|
+
async hasImageSnapshot(browserContext, taskId, snapshotKey) {
|
|
183
|
+
const info = await context.getSuiteInfo(browserContext, taskId);
|
|
184
|
+
return file.existFile(resolve(info.projectRoot, info.baselineDir, context.getSnapshotFilename(browserContext, info, snapshotKey)));
|
|
185
|
+
},
|
|
186
|
+
getSnapshotFilename(browserContext, info, snapshotKey) {
|
|
187
|
+
if (snapshotKey) return `${info.taskId}-${snapshotKey}.png`;
|
|
188
|
+
const visOptions$1 = getVisOption(browserContext);
|
|
189
|
+
if (typeof visOptions$1.snapshotKey === "string") return `${info.taskId}-${visOptions$1.snapshotKey}.png`;
|
|
190
|
+
return `${info.taskId}-${info.task.count}.png`;
|
|
191
|
+
},
|
|
192
|
+
async getSuiteInfo(browserContext, taskId) {
|
|
193
|
+
const projectState = await getSuite(browserContext);
|
|
194
|
+
const visOptions$1 = getVisOption(browserContext);
|
|
195
|
+
const moduleId = getTaskSubpath(projectState, browserContext.testPath, visOptions$1);
|
|
196
|
+
const m = projectState.modules[moduleId];
|
|
197
|
+
const task = m.tasks[taskId] = m.tasks[taskId] ?? { count: 1 };
|
|
198
|
+
return {
|
|
199
|
+
projectRoot: projectState.projectRoot,
|
|
200
|
+
suiteId: moduleId,
|
|
201
|
+
taskId,
|
|
202
|
+
baselineDir: m.baselineDir,
|
|
203
|
+
resultDir: m.resultDir,
|
|
204
|
+
diffDir: m.diffDir,
|
|
205
|
+
task
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return context;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/server/vis_server_context.ts
|
|
214
|
+
const visServerContext = createVisServerContext();
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/server/commands/_assertions.ts
|
|
218
|
+
function assertTestPathDefined(context, commandName) {
|
|
219
|
+
if (!context.testPath) throw new Error(`'commands.${commandName}' requires testPath to be defined`);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/server/commands/has_image_snapshot.ts
|
|
224
|
+
const hasImageSnapshot = async (context, taskId, snapshotKey) => {
|
|
225
|
+
assertTestPathDefined(context, "hasImageSnapshot");
|
|
226
|
+
return visServerContext.hasImageSnapshot(context, taskId, snapshotKey);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/server/commands/image_snapshot_next_index.ts
|
|
231
|
+
const imageSnapshotNextIndex = async (context, taskId) => {
|
|
232
|
+
assertTestPathDefined(context, "imageSnapshotNextIndex");
|
|
233
|
+
return visServerContext.getTaskCount(context, taskId);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region src/server/commands/load_image_snapshot_results.ts
|
|
238
|
+
const loadImageSnapshotResults = async (context, taskId) => {
|
|
239
|
+
assertTestPathDefined(context, "loadImageSnapshotResults");
|
|
240
|
+
return visServerContext.getSnapshotResults(context, taskId);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/server/browser_provider/playwright.ts
|
|
245
|
+
function playwright(context) {
|
|
246
|
+
const { page, iframe } = context;
|
|
247
|
+
return {
|
|
248
|
+
async takeScreenshot(projectRoot, relativeFilePath, selector, options) {
|
|
249
|
+
return iframe.locator(selector).screenshot({
|
|
250
|
+
path: resolve(projectRoot, relativeFilePath),
|
|
251
|
+
...options
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
async takePageScreenshot(projectRoot, relativeFilePath, options) {
|
|
255
|
+
return page.screenshot({
|
|
256
|
+
path: resolve(projectRoot, relativeFilePath),
|
|
257
|
+
...options
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/server/browser_provider/webdriverio.ts
|
|
265
|
+
function webdriverio(context) {
|
|
266
|
+
const { browser } = context;
|
|
267
|
+
return {
|
|
268
|
+
async takeScreenshot(_projectRoot, relativeFilePath, selector) {
|
|
269
|
+
return (await browser.$(`${selector}`)).saveScreenshot(relativeFilePath);
|
|
270
|
+
},
|
|
271
|
+
async takePageScreenshot(_projectRoot, relativeFilePath, options) {
|
|
272
|
+
return browser.saveScreenshot(relativeFilePath, options);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/server/browser_provider/browser_api.ts
|
|
279
|
+
function browserApi(context) {
|
|
280
|
+
if (context.provider.name === "playwright") return playwright(context);
|
|
281
|
+
if (context.provider.name === "webdriverio") return webdriverio(context);
|
|
282
|
+
throw new Error(`Unsupported provider: ${context.provider.name}`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/server/snapshot_writer.ts
|
|
287
|
+
function createSnapshotWriter({ mkdirp: mkdirp$1, writeFile: writeFile$1 } = file) {
|
|
288
|
+
return {
|
|
289
|
+
async writeBase64(filePath, data) {
|
|
290
|
+
await mkdirp$1(dirname(filePath));
|
|
291
|
+
await writeFile$1(filePath, data, { encoding: "base64" });
|
|
292
|
+
},
|
|
293
|
+
async writeBuffer(filePath, data) {
|
|
294
|
+
await mkdirp$1(dirname(filePath));
|
|
295
|
+
await writeFile$1(filePath, data);
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const snapshotWriter = createSnapshotWriter();
|
|
300
|
+
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/server/snapshot.ts
|
|
303
|
+
async function takeSnapshot(context, projectRoot, relativeFilePath, subject, options) {
|
|
304
|
+
if (isBase64String(subject)) {
|
|
305
|
+
await snapshotWriter.writeBase64(resolve(projectRoot, relativeFilePath), subject);
|
|
306
|
+
return Buffer.from(subject, "base64");
|
|
307
|
+
}
|
|
308
|
+
return takeSnapshotByBrowser(context, projectRoot, relativeFilePath, subject, options);
|
|
309
|
+
}
|
|
310
|
+
async function takeSnapshotByBrowser(context, projectRoot, relativeFilePath, subject, options) {
|
|
311
|
+
await mkdirp(dirname(resolve(projectRoot, relativeFilePath)));
|
|
312
|
+
return browserApi(context).takeScreenshot(projectRoot, relativeFilePath, subject ?? "body", { timeout: options?.timeout });
|
|
313
|
+
}
|
|
314
|
+
async function takePageSnapshot(context, projectRoot, relativeFilePath, options) {
|
|
315
|
+
await mkdirp(dirname(resolve(projectRoot, relativeFilePath)));
|
|
316
|
+
return browserApi(context).takePageScreenshot(projectRoot, relativeFilePath, {
|
|
317
|
+
timeout: options?.timeout,
|
|
318
|
+
fullPage: options?.fullPage
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/server/commands/prepare_image_snapshot_comparison.ts
|
|
324
|
+
const prepareImageSnapshotComparison = async (context, taskId, subject, options) => {
|
|
325
|
+
assertTestPathDefined(context, "prepareImageSnapshotComparison");
|
|
326
|
+
if (!options) options = {};
|
|
327
|
+
options.timeout = options.timeout ?? 3e4;
|
|
328
|
+
const projectRoot = getProjectRoot(context);
|
|
329
|
+
const info = await visServerContext.getSnapshotInfo(context, taskId, options);
|
|
330
|
+
const baselineBuffer = await file.tryReadFile(resolve(projectRoot, info.baselinePath));
|
|
331
|
+
if (!baselineBuffer) {
|
|
332
|
+
if (isBase64String(subject)) await snapshotWriter.writeBase64(resolve(projectRoot, info.baselinePath), subject);
|
|
333
|
+
else await takeSnapshotByBrowser(context, projectRoot, info.baselinePath, subject, options);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const resultBuffer = await takeSnapshot(context, projectRoot, info.resultPath, subject, options);
|
|
337
|
+
return {
|
|
338
|
+
...info,
|
|
339
|
+
projectRoot,
|
|
340
|
+
baseline: baselineBuffer.toString("base64"),
|
|
341
|
+
result: resultBuffer.toString("base64")
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/server/commands/prepare_page_image_snapshot_comparison.ts
|
|
347
|
+
const preparePageImageSnapshotComparison = async (context, taskId, options) => {
|
|
348
|
+
assertTestPathDefined(context, "preparePageImageSnapshotComparison");
|
|
349
|
+
if (!options) options = {};
|
|
350
|
+
options.timeout = options.timeout ?? 3e4;
|
|
351
|
+
const projectRoot = getProjectRoot(context);
|
|
352
|
+
const info = await visServerContext.getSnapshotInfo(context, taskId, options);
|
|
353
|
+
const baselineBuffer = await file.tryReadFile(resolve(projectRoot, info.baselinePath));
|
|
354
|
+
if (!baselineBuffer) {
|
|
355
|
+
await takePageSnapshot(context, projectRoot, info.baselinePath, options);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const resultBuffer = await takePageSnapshot(context, projectRoot, info.resultPath, options);
|
|
359
|
+
return {
|
|
360
|
+
...info,
|
|
361
|
+
projectRoot,
|
|
362
|
+
baseline: baselineBuffer.toString("base64"),
|
|
363
|
+
result: resultBuffer.toString("base64")
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/server/commands/setup_vis_suite.ts
|
|
369
|
+
const setupVisSuite = async (context) => {
|
|
370
|
+
assertTestPathDefined(context, "setupVisSuite");
|
|
371
|
+
return setupSuite(context);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/server/commands/commands.ts
|
|
376
|
+
const commands = {
|
|
377
|
+
setupVisSuite,
|
|
378
|
+
imageSnapshotNextIndex,
|
|
379
|
+
hasImageSnapshot,
|
|
380
|
+
preparePageImageSnapshotComparison,
|
|
381
|
+
prepareImageSnapshotComparison,
|
|
382
|
+
loadImageSnapshotResults
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/config/vis.ts
|
|
387
|
+
/**
|
|
388
|
+
* Create a Vite plugin for visual testing.
|
|
389
|
+
*
|
|
390
|
+
* If options are not provided, the plugin will use the default options,
|
|
391
|
+
* which enables the `auto` preset.
|
|
392
|
+
*/
|
|
393
|
+
function vis(options = { preset: "auto" }) {
|
|
394
|
+
return {
|
|
395
|
+
name: NAME,
|
|
396
|
+
config(userConfig) {
|
|
397
|
+
setVisOption(userConfig, options);
|
|
398
|
+
const preset = options?.preset;
|
|
399
|
+
return { test: {
|
|
400
|
+
browser: {
|
|
401
|
+
name: void 0,
|
|
402
|
+
commands
|
|
403
|
+
},
|
|
404
|
+
setupFiles: preset && preset !== "none" && preset !== "custom" ? [`vitest-plugin-vis/presets/${preset}`] : []
|
|
405
|
+
} };
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
//#endregion
|
|
411
|
+
export { trimCommonFolder, vis };
|
|
412
|
+
//# sourceMappingURL=config.mjs.map
|