vitest-plugin-vis 3.5.0 → 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 +60 -44
- 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/trim_common_folder.ts +1 -0
- 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 -10
- 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
package/src/shared/types.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type { Options as SsimDiffOptions } from 'ssim.js'
|
|
|
3
3
|
import type { SnapshotMeta } from '../client/snapshot_meta.ts'
|
|
4
4
|
import type { NAME } from './constants.ts'
|
|
5
5
|
|
|
6
|
+
export type Awaitable<T> = T | PromiseLike<T>
|
|
7
|
+
|
|
6
8
|
export interface ImageSnapshotTimeoutOptions {
|
|
7
9
|
/**
|
|
8
10
|
* Timeout for taking the snapshot.
|
package/src/testing.ts
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HasImageSnapshotCommand, ImageSnapshotNextIndexCommand } from '../../commands.ts';
|
|
2
|
-
import type { ImageSnapshotKeyOptions } from '../../shared/types.ts';
|
|
3
|
-
export declare function hasImageSnapshotAction(commands: ImageSnapshotNextIndexCommand & HasImageSnapshotCommand, taskId: string, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
|
|
4
|
-
//# sourceMappingURL=has_image_snapshot_action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"has_image_snapshot_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/has_image_snapshot_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AAC/F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEpE,wBAAgB,sBAAsB,CACrC,QAAQ,EAAE,6BAA6B,GAAG,uBAAuB,EACjE,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,uBAAuB,GAAG,SAAS,oBAO7C"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { LoadImageSnapshotResultsCommand } from '../../server/commands/load_image_snapshot_results.ts';
|
|
2
|
-
export declare function loadImageSnapshotResultsAction(commands: LoadImageSnapshotResultsCommand, taskId: string): Promise<import("../../server/commands/load_image_snapshot_results.ts").ImageSnapshotResult[]>;
|
|
3
|
-
//# sourceMappingURL=load_image_snapshot_results_action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load_image_snapshot_results_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/load_image_snapshot_results_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAA;AAE3G,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,+BAA+B,EAAE,MAAM,EAAE,MAAM,iGAEvG"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BrowserCommands } from '@vitest/browser/context';
|
|
2
|
-
import type { ImageSnapshotNextIndexCommand } from '../../commands.ts';
|
|
3
|
-
import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts';
|
|
4
|
-
import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
|
|
5
|
-
export declare function matchImageSnapshotAction(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, subject: any, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=match_image_snapshot_action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match_image_snapshot_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/match_image_snapshot_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,4DAA4D,CAAA;AAGvH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAIxE,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,eAAe,GAAG,qCAAqC,GAAG,6BAA6B,EACjG,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC,iBAS1C"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { assertSnapshotKeyWithoutDash } from "../../shared/asserts.js";
|
|
2
|
-
import { isBase64String } from "../../shared/base64.js";
|
|
3
|
-
import { compareImageSnapshot } from "../compare_image_snapshot.js";
|
|
4
|
-
import { convertElementToCssSelector } from "../selector.js";
|
|
5
|
-
export async function matchImageSnapshotAction(commands, taskId, subject, options) {
|
|
6
|
-
assertSnapshotKeyWithoutDash(options?.snapshotKey);
|
|
7
|
-
const info = await commands.prepareImageSnapshotComparison(taskId, parseImageSnapshotSubject(subject), options);
|
|
8
|
-
if (!info)
|
|
9
|
-
return;
|
|
10
|
-
return compareImageSnapshot(commands, taskId, info, options);
|
|
11
|
-
}
|
|
12
|
-
function parseImageSnapshotSubject(subject) {
|
|
13
|
-
if (subject instanceof Element)
|
|
14
|
-
return convertElementToCssSelector(subject);
|
|
15
|
-
if (subject?.['selector'])
|
|
16
|
-
return subject['selector'];
|
|
17
|
-
if (isBase64String(subject))
|
|
18
|
-
return subject;
|
|
19
|
-
throw new Error(`'toMatchImageSnapshot()' expects the subject to be an element, locator, or image encoded in base64 string, but got: ${subject}`);
|
|
20
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BrowserCommands } from '@vitest/browser/context';
|
|
2
|
-
import type { ImageSnapshotNextIndexCommand } from '../../commands.ts';
|
|
3
|
-
import type { PrepareImageSnapshotComparisonCommand } from '../../server/commands/prepare_image_snapshot_comparison.ts';
|
|
4
|
-
import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
|
|
5
|
-
export declare function matchPageImageSnapshotAction(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=match_page_image_snapshot_action.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match_page_image_snapshot_action.d.ts","sourceRoot":"","sources":["../../../src/client/actions/match_page_image_snapshot_action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACtE,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,4DAA4D,CAAA;AAEvH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAGxE,wBAAsB,4BAA4B,CACjD,QAAQ,EAAE,eAAe,GAAG,qCAAqC,GAAG,6BAA6B,EACjG,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC,iBAS1C"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { assertSnapshotKeyWithoutDash } from "../../shared/asserts.js";
|
|
2
|
-
import { compareImageSnapshot } from "../compare_image_snapshot.js";
|
|
3
|
-
export async function matchPageImageSnapshotAction(commands, taskId, options) {
|
|
4
|
-
assertSnapshotKeyWithoutDash(options?.snapshotKey);
|
|
5
|
-
const info = await commands.preparePageImageSnapshotComparison(taskId, options);
|
|
6
|
-
if (!info)
|
|
7
|
-
return;
|
|
8
|
-
return compareImageSnapshot(commands, taskId, info, options);
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"align_images.d.ts","sourceRoot":"","sources":["../../src/client/align_images.ts"],"names":[],"mappings":"AAIA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,CAMlH"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { getMaxSize } from "../shared/get_max_size.js";
|
|
2
|
-
import { isSameSize } from "../shared/is_same_size.js";
|
|
3
|
-
import { createImageResizer } from "./image_resizer.js";
|
|
4
|
-
export function alignImagesToSameSize(image1, image2) {
|
|
5
|
-
if (isSameSize(image1, image2))
|
|
6
|
-
return [image1, image2];
|
|
7
|
-
const size = getMaxSize(image1, image2);
|
|
8
|
-
const resize = createImageResizer(size);
|
|
9
|
-
return [resize(image1), resize(image2)];
|
|
10
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { ComparisonMethod } from '../shared/types.ts';
|
|
2
|
-
import type { SnapshotMeta } from './snapshot_meta.ts';
|
|
3
|
-
type Suite = {
|
|
4
|
-
meta: Record<string, any>;
|
|
5
|
-
suite?: Suite | undefined;
|
|
6
|
-
};
|
|
7
|
-
export type MetaTask = {
|
|
8
|
-
file?: {
|
|
9
|
-
meta: Record<string, any>;
|
|
10
|
-
} | undefined;
|
|
11
|
-
suite?: Suite | undefined;
|
|
12
|
-
meta: Record<string, any>;
|
|
13
|
-
} | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Set the snapshot options for auto snapshot.
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* beforeAll(() => setAutoSnapshotOptions(...))
|
|
19
|
-
* beforeEach(() => setAutoSnapshotOptions(...))
|
|
20
|
-
*
|
|
21
|
-
* it('...', () => {
|
|
22
|
-
* setAutoSnapshotOptions(...)
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare function setAutoSnapshotOptions<M extends ComparisonMethod>(meta: SnapshotMeta<M> | boolean): void;
|
|
27
|
-
export declare function extractAutoSnapshotOptions<M extends SnapshotMeta<any> = SnapshotMeta<any>>(task: MetaTask): M | undefined;
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=auto_snapshot_options.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto_snapshot_options.d.ts","sourceRoot":"","sources":["../../src/client/auto_snapshot_options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;CAAE,CAAA;AAErE,MAAM,MAAM,QAAQ,GACjB;IACA,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,SAAS,CAAA;IAChD,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAAA;IACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CACxB,GACD,SAAS,CAAA;AAEZ;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,gBAAgB,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,IAAI,CAYxG;AAUD,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,EACzF,IAAI,EAAE,QAAQ,GACZ,CAAC,GAAG,SAAS,CAkBf"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { assertSnapshotKeyWithoutDash } from "../shared/asserts.js";
|
|
2
|
-
import { NAME } from "../shared/constants.js";
|
|
3
|
-
import { ctx } from "./ctx.js";
|
|
4
|
-
/**
|
|
5
|
-
* Set the snapshot options for auto snapshot.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* beforeAll(() => setAutoSnapshotOptions(...))
|
|
9
|
-
* beforeEach(() => setAutoSnapshotOptions(...))
|
|
10
|
-
*
|
|
11
|
-
* it('...', () => {
|
|
12
|
-
* setAutoSnapshotOptions(...)
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export function setAutoSnapshotOptions(meta) {
|
|
17
|
-
if (typeof meta === 'object') {
|
|
18
|
-
assertSnapshotKeyWithoutDash(meta.snapshotKey);
|
|
19
|
-
}
|
|
20
|
-
const task = getTask();
|
|
21
|
-
if (!task)
|
|
22
|
-
return;
|
|
23
|
-
task.meta[NAME] = {
|
|
24
|
-
...task.meta[NAME],
|
|
25
|
-
...parseMeta(meta),
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function getTask() {
|
|
29
|
-
return ctx.getCurrentTest() ?? ctx.getCurrentSuite()?.tasks?.[0]?.file;
|
|
30
|
-
}
|
|
31
|
-
function parseMeta(meta) {
|
|
32
|
-
return typeof meta === 'boolean' ? { enable: meta } : { enable: true, ...meta };
|
|
33
|
-
}
|
|
34
|
-
export function extractAutoSnapshotOptions(task) {
|
|
35
|
-
if (!task)
|
|
36
|
-
return;
|
|
37
|
-
const list = [];
|
|
38
|
-
let current = task;
|
|
39
|
-
while (current?.suite) {
|
|
40
|
-
list.unshift(current.suite.meta);
|
|
41
|
-
current = current.suite;
|
|
42
|
-
}
|
|
43
|
-
list.unshift(task.file?.meta);
|
|
44
|
-
list.push(task.meta);
|
|
45
|
-
return list.reduce((acc, cur) => {
|
|
46
|
-
const meta = cur?.[NAME];
|
|
47
|
-
return meta ? Object.assign({}, acc, meta) : acc;
|
|
48
|
-
}, { enable: false });
|
|
49
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BrowserCommands } from '@vitest/browser/context';
|
|
2
|
-
import type { ImageSnapshotNextIndexCommand } from '../commands.ts';
|
|
3
|
-
import type { ImageSnapshotComparisonInfo, PrepareImageSnapshotComparisonCommand } from '../server/commands/prepare_image_snapshot_comparison.ts';
|
|
4
|
-
import type { ToMatchImageSnapshotOptions } from '../shared/types.ts';
|
|
5
|
-
export declare function compareImageSnapshot(commands: BrowserCommands & PrepareImageSnapshotComparisonCommand & ImageSnapshotNextIndexCommand, taskId: string, info: ImageSnapshotComparisonInfo, options?: ToMatchImageSnapshotOptions<any>): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=compare_image_snapshot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compare_image_snapshot.d.ts","sourceRoot":"","sources":["../../src/client/compare_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAG9D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EACX,2BAA2B,EAC3B,qCAAqC,EACrC,MAAM,yDAAyD,CAAA;AAEhE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAMrE,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,eAAe,GAAG,qCAAqC,GAAG,6BAA6B,EACjG,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,2BAA2B,EACjC,OAAO,CAAC,EAAE,2BAA2B,CAAC,GAAG,CAAC,iBA2D1C"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import dedent from 'dedent';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
3
|
-
import { compareImage } from "../shared/compare_image.js";
|
|
4
|
-
import { alignImagesToSameSize } from "./align_images.js";
|
|
5
|
-
import { prettifyOptions } from "./compare_image_snapshot.logic.js";
|
|
6
|
-
import { toDataURL, toImageData } from "./image_data.js";
|
|
7
|
-
import { server } from "./vitest_browser_context_proxy.js";
|
|
8
|
-
export async function compareImageSnapshot(commands, taskId, info, options) {
|
|
9
|
-
options = { ...info, ...options };
|
|
10
|
-
const baselineImage = await toImageData(info.baseline);
|
|
11
|
-
const resultImage = await toImageData(info.result);
|
|
12
|
-
const [baselineAlignedImage, resultAlignedImage] = alignImagesToSameSize(baselineImage, resultImage);
|
|
13
|
-
const { width, height } = baselineAlignedImage;
|
|
14
|
-
const diffImage = new ImageData(width, height);
|
|
15
|
-
const { pass, diffAmount } = compareImage(baselineAlignedImage.data, resultAlignedImage.data, diffImage.data, width, height, options);
|
|
16
|
-
if (pass) {
|
|
17
|
-
if (options?.expectToFail) {
|
|
18
|
-
throw new Error(dedent `Snapshot \`${taskId}\` matched but expected to fail.
|
|
19
|
-
|
|
20
|
-
Options: ${prettifyOptions(options)}
|
|
21
|
-
Diff: ${options.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}
|
|
22
|
-
|
|
23
|
-
Expected: ${resolve(info.projectRoot, info.baselinePath)}
|
|
24
|
-
Actual: ${resolve(info.projectRoot, info.resultPath)}`);
|
|
25
|
-
}
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (server.config.snapshotOptions.updateSnapshot === 'all' && !options?.expectToFail) {
|
|
29
|
-
await writeSnapshot(commands, resolve(info.projectRoot, info.baselinePath), resultImage);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
await writeSnapshot(commands, resolve(info.projectRoot, info.diffPath), diffImage);
|
|
33
|
-
throw new Error(dedent `Snapshot \`${taskId}\` mismatched
|
|
34
|
-
|
|
35
|
-
${options?.failureThreshold
|
|
36
|
-
? options?.failureThresholdType === 'percent'
|
|
37
|
-
? `Expected image to match within ${options.failureThreshold}% but was differ by ${diffAmount}%.`
|
|
38
|
-
: `Expected image to match within ${options.failureThreshold} pixels but was differ by ${diffAmount} pixels.`
|
|
39
|
-
: `Expected image to match but was differ by ${options?.failureThresholdType === 'percent' ? `${diffAmount}%` : `${diffAmount} pixels`}.`}${baselineImage.width !== resultImage.width || baselineImage.height !== resultImage.height
|
|
40
|
-
? `\nThe image size changed from ${baselineImage.width}x${baselineImage.height} to ${resultImage.width}x${resultImage.height}.`
|
|
41
|
-
: ''}
|
|
42
|
-
|
|
43
|
-
Options: ${prettifyOptions(options)}
|
|
44
|
-
|
|
45
|
-
Expected: ${resolve(info.projectRoot, info.baselinePath)}
|
|
46
|
-
Actual: ${resolve(info.projectRoot, info.resultPath)}
|
|
47
|
-
Difference: ${resolve(info.projectRoot, info.diffPath)}`);
|
|
48
|
-
}
|
|
49
|
-
async function writeSnapshot(commands, path, image) {
|
|
50
|
-
const content = (await toDataURL(image)).split(',')[1];
|
|
51
|
-
return commands.writeFile(path, content, { encoding: 'base64' });
|
|
52
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compare_image_snapshot.logic.d.ts","sourceRoot":"","sources":["../../src/client/compare_image_snapshot.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAErE,wBAAgB,eAAe,CAAC,OAAO,EAAE,2BAA2B,CAAC,GAAG,CAAC,GAAG,SAAS,UAWpF"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function prettifyOptions(options) {
|
|
2
|
-
if (!options)
|
|
3
|
-
return 'none';
|
|
4
|
-
return [
|
|
5
|
-
`failureThreshold: ${options.failureThreshold ?? 0} ${options.failureThresholdType ?? 'pixels'}`,
|
|
6
|
-
options.timeout ? `timeout: ${options.timeout} ms` : '',
|
|
7
|
-
`comparisonMethod: ${options.comparisonMethod ?? 'pixel'}`,
|
|
8
|
-
options.diffOptions ? `diffOptions: ${JSON.stringify(options.diffOptions)}` : '',
|
|
9
|
-
]
|
|
10
|
-
.filter(Boolean)
|
|
11
|
-
.join('\n ');
|
|
12
|
-
}
|
package/esm/client/ctx.d.ts
DELETED
package/esm/client/ctx.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ctx.d.ts","sourceRoot":"","sources":["../../src/client/ctx.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG;iBACW,OAAO,GAAG,SAAS;;;;CAQ7C,CAAA"}
|
package/esm/client/ctx.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getCurrentSuite, getCurrentTest } from "./vitest_suite_proxy.js";
|
|
2
|
-
export const ctx = {
|
|
3
|
-
autoEnabled: undefined,
|
|
4
|
-
getCurrentTest,
|
|
5
|
-
getCurrentSuite,
|
|
6
|
-
__test__reset() {
|
|
7
|
-
ctx.getCurrentTest = getCurrentTest;
|
|
8
|
-
ctx.getCurrentSuite = getCurrentSuite;
|
|
9
|
-
ctx.autoEnabled = undefined;
|
|
10
|
-
},
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../../../src/client/expect/augment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE9E,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,IAAI,CAAC;QAEd,UAAU,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,oBAAoB;SAAG;KACxD;CACD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"expectation_result.d.ts","sourceRoot":"","sources":["../../../src/client/expect/expectation_result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAE3D,eAAO,MAAM,OAAO,EAAE,qBAIrB,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../src/client/expect/extend.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AsyncExpectationResult } from '@vitest/expect';
|
|
2
|
-
import type { ToMatchImageSnapshotOptions } from '../../shared/types.ts';
|
|
3
|
-
export declare function toMatchImageSnapshot(
|
|
4
|
-
/**
|
|
5
|
-
* The element or locator to take the snapshot of,
|
|
6
|
-
* or the base64 value of the image to compare against.
|
|
7
|
-
*/
|
|
8
|
-
subject: any, options?: ToMatchImageSnapshotOptions | undefined): AsyncExpectationResult;
|
|
9
|
-
//# sourceMappingURL=to_match_image_snapshot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to_match_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAMxE,wBAAgB,oBAAoB;AACnC;;;GAGG;AACH,OAAO,EAAE,GAAG,EACZ,OAAO,CAAC,EAAE,2BAA2B,GAAG,SAAS,GAC/C,sBAAsB,CAcxB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { commands } from '@vitest/browser/context';
|
|
2
|
-
import { matchImageSnapshotAction } from "../actions/match_image_snapshot_action.js";
|
|
3
|
-
import { ctx } from "../ctx.js";
|
|
4
|
-
import { toTaskId } from "../task_id.js";
|
|
5
|
-
import { success } from "./expectation_result.js";
|
|
6
|
-
export function toMatchImageSnapshot(
|
|
7
|
-
/**
|
|
8
|
-
* The element or locator to take the snapshot of,
|
|
9
|
-
* or the base64 value of the image to compare against.
|
|
10
|
-
*/
|
|
11
|
-
subject, options) {
|
|
12
|
-
const test = ctx.getCurrentTest();
|
|
13
|
-
if (!test) {
|
|
14
|
-
throw new Error('`toMatchImageSnapshot()` must be called in a test.');
|
|
15
|
-
}
|
|
16
|
-
if (test.concurrent) {
|
|
17
|
-
throw new Error('`toMatchImageSnapshot()` cannot be called in a concurrent test because ' +
|
|
18
|
-
"concurrent tests run at the same time in the same iframe and affect each other's environment.");
|
|
19
|
-
}
|
|
20
|
-
return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success);
|
|
21
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ComparisonMethod, ToMatchImageSnapshotOptions } from '../../shared/types.ts';
|
|
2
|
-
export interface ImageSnapshotMatcher {
|
|
3
|
-
toMatchImageSnapshot<M extends ComparisonMethod>(options?: ToMatchImageSnapshotOptions<M> | undefined): Promise<void>;
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=to_match_image_snapshot.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to_match_image_snapshot.types.d.ts","sourceRoot":"","sources":["../../../src/client/expect/to_match_image_snapshot.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAE1F,MAAM,WAAW,oBAAoB;IACpC,oBAAoB,CAAC,CAAC,SAAS,gBAAgB,EAAE,OAAO,CAAC,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image_data.d.ts","sourceRoot":"","sources":["../../src/client/image_data.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,sBAkBzC;AAED,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,mBAenD"}
|
package/esm/client/image_data.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export function toImageData(base64) {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
const img = new Image();
|
|
4
|
-
img.src = `data:image/png;base64,${base64}`;
|
|
5
|
-
img.onload = () => {
|
|
6
|
-
const canvas = document.createElement('canvas');
|
|
7
|
-
canvas.width = img.width;
|
|
8
|
-
canvas.height = img.height;
|
|
9
|
-
const ctx = canvas.getContext('2d');
|
|
10
|
-
ctx.drawImage(img, 0, 0);
|
|
11
|
-
resolve(ctx.getImageData(0, 0, canvas.width, canvas.height));
|
|
12
|
-
};
|
|
13
|
-
img.onerror = () => {
|
|
14
|
-
reject(new Error('Failed to load image'));
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
export async function toDataURL(imageData) {
|
|
19
|
-
const canvas = document.createElement('canvas');
|
|
20
|
-
canvas.width = imageData.width;
|
|
21
|
-
canvas.height = imageData.height;
|
|
22
|
-
const ctx = canvas.getContext('2d');
|
|
23
|
-
ctx.putImageData(imageData, 0, 0);
|
|
24
|
-
return new Promise((resolve) => {
|
|
25
|
-
canvas.toBlob((blob) => {
|
|
26
|
-
const reader = new FileReader();
|
|
27
|
-
reader.onload = () => {
|
|
28
|
-
resolve(reader.result);
|
|
29
|
-
};
|
|
30
|
-
reader.readAsDataURL(blob);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const createImageResizer: ({ width, height }: {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
}) => (image: ImageData) => ImageData;
|
|
5
|
-
export declare const createImageResizer2: ({ width, height }: {
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
}) => (image: ImageData) => ImageData;
|
|
9
|
-
//# sourceMappingURL=image_resizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image_resizer.d.ts","sourceRoot":"","sources":["../../src/client/image_resizer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,GAC7B,mBAAmB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,MACpD,OAAO,SAAS,cA2BhB,CAAA;AAGF,eAAO,MAAM,mBAAmB,GAC9B,mBAAmB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,MACpD,OAAO,SAAS,cAsBhB,CAAA"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { isSameSize } from "../shared/is_same_size.js";
|
|
2
|
-
export const createImageResizer = ({ width, height }) => (image) => {
|
|
3
|
-
if (isSameSize(image, { width, height }))
|
|
4
|
-
return image;
|
|
5
|
-
const inArea = (x, y) => y <= image.height && x <= image.width;
|
|
6
|
-
const data = new Uint8ClampedArray(width * height * 4);
|
|
7
|
-
const result = new ImageData(data, width, height, { colorSpace: image.colorSpace });
|
|
8
|
-
for (let y = 0; y < height; y++) {
|
|
9
|
-
for (let x = 0; x < width; x++) {
|
|
10
|
-
const idx = (width * y + x) << 2;
|
|
11
|
-
if (inArea(x, y)) {
|
|
12
|
-
const old = (image.width * y + x) << 2;
|
|
13
|
-
result.data[idx] = image.data[old];
|
|
14
|
-
result.data[idx + 1] = image.data[old + 1];
|
|
15
|
-
result.data[idx + 2] = image.data[old + 2];
|
|
16
|
-
result.data[idx + 3] = image.data[old + 3];
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
result.data[idx] = 0;
|
|
20
|
-
result.data[idx + 1] = 0;
|
|
21
|
-
result.data[idx + 2] = 0;
|
|
22
|
-
result.data[idx + 3] = 64;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
// slower
|
|
29
|
-
export const createImageResizer2 = ({ width, height }) => (image) => {
|
|
30
|
-
if (isSameSize(image, { width, height }))
|
|
31
|
-
return image;
|
|
32
|
-
const inArea = (x, y) => y <= image.height && x <= image.width;
|
|
33
|
-
const data = new Uint8ClampedArray(width * height * 4);
|
|
34
|
-
const result = new ImageData(data, width, height, { colorSpace: image.colorSpace });
|
|
35
|
-
const copyBytes = image.width * 4;
|
|
36
|
-
for (let y = 0; y < height; y++) {
|
|
37
|
-
result.data.set(image.data.slice(y * image.width, copyBytes), y * width * 4);
|
|
38
|
-
for (let x = image.width; x < width; x++) {
|
|
39
|
-
const idx = (width * y + x) << 2;
|
|
40
|
-
if (!inArea(x, y)) {
|
|
41
|
-
result.data[idx] = 0;
|
|
42
|
-
result.data[idx + 1] = 0;
|
|
43
|
-
result.data[idx + 2] = 0;
|
|
44
|
-
result.data[idx + 3] = 64;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image_snapshot_options.d.ts","sourceRoot":"","sources":["../../src/client/image_snapshot_options.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// import type { ToMatchImageSnapshotOptions } from '../shared/types.ts'
|
|
2
|
-
export {};
|
|
3
|
-
// export function parseImageSnapshotOptions(taskId: string, options: ToMatchImageSnapshotOptions<any> | undefined) {
|
|
4
|
-
// const { snapshotKey, ...rest } = options ?? {}
|
|
5
|
-
// return snapshotKey ? { ...options, snapshotFileId: `${taskId}-${snapshotKey}` } : rest
|
|
6
|
-
// }
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { HasImageSnapshotAction } from './has_image_snapshot.ts';
|
|
2
|
-
import type { ToMatchImageSnapshotAction } from './to_match_image_snapshot.ts';
|
|
3
|
-
declare module '@vitest/browser/context' {
|
|
4
|
-
interface BrowserPage extends HasImageSnapshotAction, ToMatchImageSnapshotAction {
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=augment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../../../src/client/page/augment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAA;AAE9E,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,WAAY,SAAQ,sBAAsB,EAAE,0BAA0B;KAAG;CACnF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../../src/client/page/extend.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,CAAA"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type BrowserPage } from '@vitest/browser/context';
|
|
2
|
-
import type { ImageSnapshotKeyOptions } from '../../shared/types.ts';
|
|
3
|
-
export interface HasImageSnapshotAction {
|
|
4
|
-
/**
|
|
5
|
-
* Check if the snapshot image exists.
|
|
6
|
-
*/
|
|
7
|
-
hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
|
|
8
|
-
}
|
|
9
|
-
export declare function hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>;
|
|
10
|
-
//# sourceMappingURL=has_image_snapshot.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"has_image_snapshot.d.ts","sourceRoot":"","sources":["../../../src/client/page/has_image_snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,yBAAyB,CAAA;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAKpE,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACpG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,SAAS,oBAahG"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { commands } from '@vitest/browser/context';
|
|
2
|
-
import { hasImageSnapshotAction } from "../actions/has_image_snapshot_action.js";
|
|
3
|
-
import { ctx } from "../ctx.js";
|
|
4
|
-
import { toTaskId } from "../task_id.js";
|
|
5
|
-
export function hasImageSnapshot(options) {
|
|
6
|
-
const test = ctx.getCurrentTest();
|
|
7
|
-
if (!test) {
|
|
8
|
-
throw new Error('`hasImageSnapshot()` must be called in a test.');
|
|
9
|
-
}
|
|
10
|
-
if (test.concurrent) {
|
|
11
|
-
throw new Error('`hasImageSnapshot()` cannot be called in a concurrent test because ' +
|
|
12
|
-
"concurrent tests run at the same time in the same iframe and affect each other's environment. ");
|
|
13
|
-
}
|
|
14
|
-
return hasImageSnapshotAction(commands, toTaskId(test), options);
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ComparisonMethod, ToMatchPageImageSnapshotOptions } from '../../shared/types.ts';
|
|
2
|
-
export interface ToMatchImageSnapshotAction {
|
|
3
|
-
toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(options?: ToMatchPageImageSnapshotOptions<M> | undefined): Promise<void>;
|
|
4
|
-
}
|
|
5
|
-
export declare function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(options?: ToMatchPageImageSnapshotOptions<M> | undefined): Promise<void>;
|
|
6
|
-
//# sourceMappingURL=to_match_image_snapshot.d.ts.map
|