vitest-plugin-vis 3.5.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/asserts--HSSlgPD.mjs +8 -0
- package/dist/asserts--HSSlgPD.mjs.map +1 -0
- package/dist/augment-BJmy1S7i.d.mts +31 -0
- package/dist/augment-BJmy1S7i.d.mts.map +1 -0
- package/dist/auto_snapshot_options-CAD43Zkp.mjs +90 -0
- package/dist/auto_snapshot_options-CAD43Zkp.mjs.map +1 -0
- package/dist/auto_snapshot_options-CaQCXDdi.d.mts +45 -0
- package/dist/auto_snapshot_options-CaQCXDdi.d.mts.map +1 -0
- package/dist/base64-CHSENEAO.mjs +8 -0
- package/dist/base64-CHSENEAO.mjs.map +1 -0
- package/dist/client-api.d.mts +141 -0
- package/dist/client-api.d.mts.map +1 -0
- package/dist/client-api.mjs +14 -0
- package/dist/client-api.mjs.map +1 -0
- package/dist/config.d.mts +28 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +412 -0
- package/dist/config.mjs.map +1 -0
- package/dist/constants-CTBaz8Ml.mjs +10 -0
- package/dist/constants-CTBaz8Ml.mjs.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +6 -0
- package/dist/presets/auto.d.mts +1 -0
- package/dist/presets/auto.mjs +19 -0
- package/dist/presets/auto.mjs.map +1 -0
- package/dist/presets/enable.d.mts +1 -0
- package/dist/presets/enable.mjs +15 -0
- package/dist/presets/enable.mjs.map +1 -0
- package/dist/presets/manual.d.mts +1 -0
- package/dist/presets/manual.mjs +15 -0
- package/dist/presets/manual.mjs.map +1 -0
- package/dist/server-utils.d.mts +19 -0
- package/dist/server-utils.d.mts.map +1 -0
- package/dist/server-utils.mjs +4 -0
- package/dist/setup-BWgIDtv-.mjs +141 -0
- package/dist/setup-BWgIDtv-.mjs.map +1 -0
- package/dist/setup.d.mts +110 -0
- package/dist/setup.d.mts.map +1 -0
- package/dist/setup.mjs +8 -0
- package/dist/setup_vis_suite-C6JGGT7B.d.mts +17 -0
- package/dist/setup_vis_suite-C6JGGT7B.d.mts.map +1 -0
- package/dist/snapshot_path-7GliOSH_.mjs +58 -0
- package/dist/snapshot_path-7GliOSH_.mjs.map +1 -0
- package/dist/src-CSQnlFa9.mjs +1 -0
- package/dist/task_id-DnS9_4Ub.mjs +316 -0
- package/dist/task_id-DnS9_4Ub.mjs.map +1 -0
- package/dist/testing.d.mts +12 -0
- package/dist/testing.d.mts.map +1 -0
- package/dist/testing.mjs +65550 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/to_match_image_snapshot.types-p-zilA_M.d.mts +9 -0
- package/dist/to_match_image_snapshot.types-p-zilA_M.d.mts.map +1 -0
- package/dist/trim_common_folder-ModiubEJ.d.mts +9 -0
- package/dist/trim_common_folder-ModiubEJ.d.mts.map +1 -0
- package/dist/types-DFb23VE1.d.mts +110 -0
- package/dist/types-DFb23VE1.d.mts.map +1 -0
- package/dist/types-Do1N7g4c.d.mts +63 -0
- package/dist/types-Do1N7g4c.d.mts.map +1 -0
- package/dist/vis_server_context.types-Ce1f9vOO.d.mts +1 -0
- package/package.json +55 -39
- package/readme.md +58 -6
- package/src/client/actions/match_image_snapshot_action.ts +1 -1
- package/src/client/actions/match_page_image_snapshot_action.ts +1 -1
- package/src/client/auto_snapshot_options.ts +16 -1
- package/src/client/compare_image_snapshot.ts +1 -1
- package/src/client/expect/to_match_image_snapshot.ts +1 -1
- package/src/client/page/extend.ts +1 -1
- package/src/client/page/has_image_snapshot.mdx +1 -1
- package/src/client/page/has_image_snapshot.ts +1 -1
- package/src/client/page/to_match_image_snapshot.mdx +1 -1
- package/src/client/page/to_match_image_snapshot.ts +1 -1
- package/src/client/setup/create_vis.ts +16 -14
- package/src/client/setup/vis.ctx.ts +4 -3
- package/src/client/setup/vis.ts +1 -1
- package/src/client/snapshot_meta.ts +5 -0
- package/src/client/vitest_browser_context_proxy.ts +3 -3
- package/src/config/vis.ts +4 -4
- package/src/server/browser_provider/browser_api.ts +2 -2
- package/src/server/browser_provider/playwright.ts +6 -4
- package/src/server/browser_provider/webdriverio.ts +3 -3
- package/src/server/commands/_assertions.ts +3 -3
- package/src/server/commands/augment.ts +1 -1
- package/src/server/commands/has_image_snapshot.ts +2 -2
- package/src/server/commands/image_snapshot_next_index.ts +2 -2
- package/src/server/commands/load_image_snapshot_results.ts +2 -3
- package/src/server/commands/prepare_image_snapshot_comparison.ts +2 -2
- package/src/server/commands/prepare_page_image_snapshot_comparison.ts +2 -2
- package/src/server/commands/setup_vis_suite.ts +3 -3
- package/src/server/project.ts +8 -7
- package/src/server/snapshot.ts +4 -4
- package/src/server/snapshot_path.ts +6 -5
- package/src/server/suite.ts +7 -12
- package/src/server/testing/stubBrowserCommandContext.ts +16 -0
- package/src/{testing → server/testing}/stubSuite.ts +7 -9
- package/src/server/testing/stubUserConfig.ts +6 -0
- package/src/server/vis_options.ts +4 -5
- package/src/server/vis_server_context.logic.ts +7 -7
- package/src/server/vis_server_context.types.ts +31 -26
- package/src/shared/types.ts +2 -0
- package/src/testing.ts +0 -1
- package/esm/client/actions/has_image_snapshot_action.d.ts +0 -4
- package/esm/client/actions/has_image_snapshot_action.d.ts.map +0 -1
- package/esm/client/actions/has_image_snapshot_action.js +0 -6
- package/esm/client/actions/load_image_snapshot_results_action.d.ts +0 -3
- package/esm/client/actions/load_image_snapshot_results_action.d.ts.map +0 -1
- package/esm/client/actions/load_image_snapshot_results_action.js +0 -3
- package/esm/client/actions/match_image_snapshot_action.d.ts +0 -6
- package/esm/client/actions/match_image_snapshot_action.d.ts.map +0 -1
- package/esm/client/actions/match_image_snapshot_action.js +0 -20
- package/esm/client/actions/match_page_image_snapshot_action.d.ts +0 -6
- package/esm/client/actions/match_page_image_snapshot_action.d.ts.map +0 -1
- package/esm/client/actions/match_page_image_snapshot_action.js +0 -9
- package/esm/client/align_images.d.ts +0 -2
- package/esm/client/align_images.d.ts.map +0 -1
- package/esm/client/align_images.js +0 -10
- package/esm/client/auto_snapshot_options.d.ts +0 -29
- package/esm/client/auto_snapshot_options.d.ts.map +0 -1
- package/esm/client/auto_snapshot_options.js +0 -49
- package/esm/client/compare_image_snapshot.d.ts +0 -6
- package/esm/client/compare_image_snapshot.d.ts.map +0 -1
- package/esm/client/compare_image_snapshot.js +0 -52
- package/esm/client/compare_image_snapshot.logic.d.ts +0 -3
- package/esm/client/compare_image_snapshot.logic.d.ts.map +0 -1
- package/esm/client/compare_image_snapshot.logic.js +0 -12
- package/esm/client/ctx.d.ts +0 -7
- package/esm/client/ctx.d.ts.map +0 -1
- package/esm/client/ctx.js +0 -11
- package/esm/client/expect/augment.d.ts +0 -8
- package/esm/client/expect/augment.d.ts.map +0 -1
- package/esm/client/expect/augment.js +0 -1
- package/esm/client/expect/expectation_result.d.ts +0 -3
- package/esm/client/expect/expectation_result.d.ts.map +0 -1
- package/esm/client/expect/expectation_result.js +0 -5
- package/esm/client/expect/extend.d.ts +0 -2
- package/esm/client/expect/extend.d.ts.map +0 -1
- package/esm/client/expect/extend.js +0 -4
- package/esm/client/expect/to_match_image_snapshot.d.ts +0 -9
- package/esm/client/expect/to_match_image_snapshot.d.ts.map +0 -1
- package/esm/client/expect/to_match_image_snapshot.js +0 -21
- package/esm/client/expect/to_match_image_snapshot.types.d.ts +0 -5
- package/esm/client/expect/to_match_image_snapshot.types.d.ts.map +0 -1
- package/esm/client/expect/to_match_image_snapshot.types.js +0 -1
- package/esm/client/image_data.d.ts +0 -3
- package/esm/client/image_data.d.ts.map +0 -1
- package/esm/client/image_data.js +0 -33
- package/esm/client/image_resizer.d.ts +0 -9
- package/esm/client/image_resizer.d.ts.map +0 -1
- package/esm/client/image_resizer.js +0 -49
- package/esm/client/image_snapshot_options.d.ts +0 -2
- package/esm/client/image_snapshot_options.d.ts.map +0 -1
- package/esm/client/image_snapshot_options.js +0 -6
- package/esm/client/page/augment.d.ts +0 -7
- package/esm/client/page/augment.d.ts.map +0 -1
- package/esm/client/page/augment.js +0 -1
- package/esm/client/page/extend.d.ts +0 -2
- package/esm/client/page/extend.d.ts.map +0 -1
- package/esm/client/page/extend.js +0 -5
- package/esm/client/page/has_image_snapshot.d.ts +0 -10
- package/esm/client/page/has_image_snapshot.d.ts.map +0 -1
- package/esm/client/page/has_image_snapshot.js +0 -15
- package/esm/client/page/to_match_image_snapshot.d.ts +0 -6
- package/esm/client/page/to_match_image_snapshot.d.ts.map +0 -1
- package/esm/client/page/to_match_image_snapshot.js +0 -15
- package/esm/client/selector.d.ts +0 -7
- package/esm/client/selector.d.ts.map +0 -1
- package/esm/client/selector.js +0 -97
- package/esm/client/setup/create_vis.d.ts +0 -96
- package/esm/client/setup/create_vis.d.ts.map +0 -1
- package/esm/client/setup/create_vis.js +0 -109
- package/esm/client/setup/vis.ctx.d.ts +0 -12
- package/esm/client/setup/vis.ctx.d.ts.map +0 -1
- package/esm/client/setup/vis.ctx.js +0 -32
- package/esm/client/setup/vis.d.ts +0 -5
- package/esm/client/setup/vis.d.ts.map +0 -1
- package/esm/client/setup/vis.js +0 -6
- package/esm/client/should_take_snapshot.d.ts +0 -3
- package/esm/client/should_take_snapshot.d.ts.map +0 -1
- package/esm/client/should_take_snapshot.js +0 -3
- package/esm/client/snapshot_meta.d.ts +0 -6
- package/esm/client/snapshot_meta.d.ts.map +0 -1
- package/esm/client/snapshot_meta.js +0 -1
- package/esm/client/task_id.d.ts +0 -7
- package/esm/client/task_id.d.ts.map +0 -1
- package/esm/client/task_id.js +0 -10
- package/esm/client/vitest_browser_context_proxy.d.ts +0 -32
- package/esm/client/vitest_browser_context_proxy.d.ts.map +0 -1
- package/esm/client/vitest_browser_context_proxy.js +0 -11
- package/esm/client/vitest_suite_proxy.d.ts +0 -7
- package/esm/client/vitest_suite_proxy.d.ts.map +0 -1
- package/esm/client/vitest_suite_proxy.js +0 -8
- package/esm/client-api.d.ts +0 -12
- package/esm/client-api.d.ts.map +0 -1
- package/esm/client-api.js +0 -9
- package/esm/commands.d.ts +0 -5
- package/esm/commands.d.ts.map +0 -1
- package/esm/commands.js +0 -4
- package/esm/config/types.d.ts +0 -60
- package/esm/config/types.d.ts.map +0 -1
- package/esm/config/types.js +0 -1
- package/esm/config/vis.d.ts +0 -28
- package/esm/config/vis.d.ts.map +0 -1
- package/esm/config/vis.js +0 -27
- package/esm/config.d.ts +0 -4
- package/esm/config.d.ts.map +0 -1
- package/esm/config.js +0 -2
- package/esm/index.d.ts +0 -5
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -4
- package/esm/presets/auto.d.ts +0 -2
- package/esm/presets/auto.d.ts.map +0 -1
- package/esm/presets/auto.js +0 -8
- package/esm/presets/enable.d.ts +0 -2
- package/esm/presets/enable.d.ts.map +0 -1
- package/esm/presets/enable.js +0 -4
- package/esm/presets/manual.d.ts +0 -2
- package/esm/presets/manual.d.ts.map +0 -1
- package/esm/presets/manual.js +0 -4
- package/esm/server/browser_provider/browser_api.d.ts +0 -3
- package/esm/server/browser_provider/browser_api.d.ts.map +0 -1
- package/esm/server/browser_provider/browser_api.js +0 -11
- package/esm/server/browser_provider/playwright.d.ts +0 -4
- package/esm/server/browser_provider/playwright.d.ts.map +0 -1
- package/esm/server/browser_provider/playwright.js +0 -18
- package/esm/server/browser_provider/types.d.ts +0 -10
- package/esm/server/browser_provider/types.d.ts.map +0 -1
- package/esm/server/browser_provider/types.js +0 -1
- package/esm/server/browser_provider/webdriverio.d.ts +0 -4
- package/esm/server/browser_provider/webdriverio.d.ts.map +0 -1
- package/esm/server/browser_provider/webdriverio.js +0 -12
- package/esm/server/commands/_assertions.d.ts +0 -5
- package/esm/server/commands/_assertions.d.ts.map +0 -1
- package/esm/server/commands/_assertions.js +0 -11
- package/esm/server/commands/augment.d.ts +0 -11
- package/esm/server/commands/augment.d.ts.map +0 -1
- package/esm/server/commands/augment.js +0 -1
- package/esm/server/commands/commands.d.ts +0 -9
- package/esm/server/commands/commands.d.ts.map +0 -1
- package/esm/server/commands/commands.js +0 -14
- package/esm/server/commands/has_image_snapshot.d.ts +0 -6
- package/esm/server/commands/has_image_snapshot.d.ts.map +0 -1
- package/esm/server/commands/has_image_snapshot.js +0 -6
- package/esm/server/commands/image_snapshot_next_index.d.ts +0 -9
- package/esm/server/commands/image_snapshot_next_index.d.ts.map +0 -1
- package/esm/server/commands/image_snapshot_next_index.js +0 -6
- package/esm/server/commands/load_image_snapshot_results.d.ts +0 -21
- package/esm/server/commands/load_image_snapshot_results.d.ts.map +0 -1
- package/esm/server/commands/load_image_snapshot_results.js +0 -6
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts +0 -38
- package/esm/server/commands/prepare_image_snapshot_comparison.d.ts.map +0 -1
- package/esm/server/commands/prepare_image_snapshot_comparison.js +0 -34
- package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts +0 -35
- package/esm/server/commands/prepare_page_image_snapshot_comparison.d.ts.map +0 -1
- package/esm/server/commands/prepare_page_image_snapshot_comparison.js +0 -27
- package/esm/server/commands/setup_vis_suite.d.ts +0 -15
- package/esm/server/commands/setup_vis_suite.d.ts.map +0 -1
- package/esm/server/commands/setup_vis_suite.js +0 -6
- package/esm/server/commands/types.d.ts +0 -3
- package/esm/server/commands/types.d.ts.map +0 -1
- package/esm/server/commands/types.js +0 -1
- package/esm/server/externals/file.d.ts +0 -10
- package/esm/server/externals/file.d.ts.map +0 -1
- package/esm/server/externals/file.js +0 -20
- package/esm/server/project.d.ts +0 -21
- package/esm/server/project.d.ts.map +0 -1
- package/esm/server/project.js +0 -13
- package/esm/server/snapshot.d.ts +0 -6
- package/esm/server/snapshot.d.ts.map +0 -1
- package/esm/server/snapshot.js +0 -29
- package/esm/server/snapshot_path.d.ts +0 -14
- package/esm/server/snapshot_path.d.ts.map +0 -1
- package/esm/server/snapshot_path.js +0 -34
- package/esm/server/snapshot_writer.d.ts +0 -13
- package/esm/server/snapshot_writer.d.ts.map +0 -1
- package/esm/server/snapshot_writer.js +0 -15
- package/esm/server/suite.d.ts +0 -54
- package/esm/server/suite.d.ts.map +0 -1
- package/esm/server/suite.js +0 -73
- package/esm/server/vis_options.d.ts +0 -19
- package/esm/server/vis_options.d.ts.map +0 -1
- package/esm/server/vis_options.js +0 -14
- package/esm/server/vis_server_context.d.ts +0 -50
- package/esm/server/vis_server_context.d.ts.map +0 -1
- package/esm/server/vis_server_context.deps.d.ts +0 -29
- package/esm/server/vis_server_context.deps.d.ts.map +0 -1
- package/esm/server/vis_server_context.deps.js +0 -10
- package/esm/server/vis_server_context.js +0 -2
- package/esm/server/vis_server_context.logic.d.ts +0 -53
- package/esm/server/vis_server_context.logic.d.ts.map +0 -1
- package/esm/server/vis_server_context.logic.js +0 -79
- package/esm/server/vis_server_context.types.d.ts +0 -54
- package/esm/server/vis_server_context.types.d.ts.map +0 -1
- package/esm/server/vis_server_context.types.js +0 -1
- package/esm/server-utils.d.ts +0 -4
- package/esm/server-utils.d.ts.map +0 -1
- package/esm/server-utils.js +0 -3
- package/esm/setup.d.ts +0 -5
- package/esm/setup.d.ts.map +0 -1
- package/esm/setup.js +0 -5
- package/esm/shared/asserts.d.ts +0 -2
- package/esm/shared/asserts.d.ts.map +0 -1
- package/esm/shared/asserts.js +0 -5
- package/esm/shared/base64.d.ts +0 -2
- package/esm/shared/base64.d.ts.map +0 -1
- package/esm/shared/base64.js +0 -3
- package/esm/shared/compare_image.d.ts +0 -6
- package/esm/shared/compare_image.d.ts.map +0 -1
- package/esm/shared/compare_image.js +0 -42
- package/esm/shared/constants.d.ts +0 -6
- package/esm/shared/constants.d.ts.map +0 -1
- package/esm/shared/constants.js +0 -5
- package/esm/shared/convert_threshold_unit.d.ts +0 -6
- package/esm/shared/convert_threshold_unit.d.ts.map +0 -1
- package/esm/shared/convert_threshold_unit.js +0 -10
- package/esm/shared/get_max_size.d.ts +0 -11
- package/esm/shared/get_max_size.d.ts.map +0 -1
- package/esm/shared/get_max_size.js +0 -5
- package/esm/shared/is_same_size.d.ts +0 -8
- package/esm/shared/is_same_size.d.ts.map +0 -1
- package/esm/shared/is_same_size.js +0 -3
- package/esm/shared/trim_common_folder.d.ts +0 -6
- package/esm/shared/trim_common_folder.d.ts.map +0 -1
- package/esm/shared/trim_common_folder.js +0 -11
- package/esm/shared/types.d.ts +0 -90
- package/esm/shared/types.d.ts.map +0 -1
- package/esm/shared/types.js +0 -1
- package/esm/testing/constants.d.ts +0 -9
- package/esm/testing/constants.d.ts.map +0 -1
- package/esm/testing/constants.js +0 -1933
- package/esm/testing/stubBrowserCommandContext.d.ts +0 -8
- package/esm/testing/stubBrowserCommandContext.d.ts.map +0 -1
- package/esm/testing/stubBrowserCommandContext.js +0 -12
- package/esm/testing/stubSuite.d.ts +0 -10
- package/esm/testing/stubSuite.d.ts.map +0 -1
- package/esm/testing/stubSuite.js +0 -27
- package/esm/testing/stubUserConfig.d.ts +0 -7
- package/esm/testing/stubUserConfig.d.ts.map +0 -1
- package/esm/testing/stubUserConfig.js +0 -4
- package/esm/testing.d.ts +0 -3
- package/esm/testing.d.ts.map +0 -1
- package/esm/testing.js +0 -2
- package/src/testing/stubBrowserCommandContext.ts +0 -16
- package/src/testing/stubUserConfig.ts +0 -6
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { n as setAutoSnapshotOptions, r as ctx, t as extractAutoSnapshotOptions } from "./auto_snapshot_options-CAD43Zkp.mjs";
|
|
2
|
+
import { a as hasImageSnapshotAction, i as matchImageSnapshotAction, n as success, r as matchPageImageSnapshotAction, t as toTaskId } from "./task_id-DnS9_4Ub.mjs";
|
|
3
|
+
import dedent from "dedent";
|
|
4
|
+
import { afterEach, beforeAll, expect } from "vitest";
|
|
5
|
+
import { commands, page } from "vitest/browser";
|
|
6
|
+
|
|
7
|
+
//#region src/client/expect/to_match_image_snapshot.ts
|
|
8
|
+
function toMatchImageSnapshot$1(subject, options) {
|
|
9
|
+
const test = ctx.getCurrentTest();
|
|
10
|
+
if (!test) throw new Error("`toMatchImageSnapshot()` must be called in a test.");
|
|
11
|
+
if (test.concurrent) throw new Error("`toMatchImageSnapshot()` cannot be called in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment.");
|
|
12
|
+
return matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/client/expect/extend.ts
|
|
17
|
+
expect.extend({ toMatchImageSnapshot: toMatchImageSnapshot$1 });
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/client/page/has_image_snapshot.ts
|
|
21
|
+
function hasImageSnapshot(options) {
|
|
22
|
+
const test = ctx.getCurrentTest();
|
|
23
|
+
if (!test) throw new Error("`hasImageSnapshot()` must be called in a test.");
|
|
24
|
+
if (test.concurrent) throw new Error("`hasImageSnapshot()` cannot be called in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment. ");
|
|
25
|
+
return hasImageSnapshotAction(commands, toTaskId(test), options);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/client/page/to_match_image_snapshot.ts
|
|
30
|
+
function toMatchImageSnapshot(options) {
|
|
31
|
+
const test = ctx.getCurrentTest();
|
|
32
|
+
if (!test) throw new Error("`toMatchImageSnapshot()` must be called in a test.");
|
|
33
|
+
if (test.concurrent) throw new Error("`toMatchImageSnapshot()` cannot be called in a concurrent test because concurrent tests run at the same time in the same iframe and affect each other's environment.");
|
|
34
|
+
return matchPageImageSnapshotAction(commands, toTaskId(test), options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/client/page/extend.ts
|
|
39
|
+
page.extend({
|
|
40
|
+
hasImageSnapshot,
|
|
41
|
+
toMatchImageSnapshot
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/client/should_take_snapshot.ts
|
|
46
|
+
function shouldTakeSnapshot(meta) {
|
|
47
|
+
return document.body.childElementCount > 0 && meta?.enable;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/client/setup/create_vis.ts
|
|
52
|
+
function createVis(commands$1) {
|
|
53
|
+
let subject;
|
|
54
|
+
const vis$1 = {
|
|
55
|
+
setup(options) {
|
|
56
|
+
if (!options || options.auto === false) beforeAll(vis$1.beforeAll.setup);
|
|
57
|
+
else beforeAll(async () => {
|
|
58
|
+
await vis$1.beforeAll.setup();
|
|
59
|
+
setAutoSnapshotOptions(true);
|
|
60
|
+
});
|
|
61
|
+
if (typeof options?.auto === "function") afterEach(vis$1.afterEach.matchPerTheme({ auto: options.auto }));
|
|
62
|
+
else if (typeof options?.auto === "object") afterEach(vis$1.afterEach.matchPerTheme(options.auto));
|
|
63
|
+
else afterEach(vis$1.afterEach.matchImageSnapshot);
|
|
64
|
+
},
|
|
65
|
+
presets: {
|
|
66
|
+
enable() {
|
|
67
|
+
beforeAll(vis$1.beforeAll.setup);
|
|
68
|
+
afterEach(vis$1.afterEach.matchImageSnapshot);
|
|
69
|
+
},
|
|
70
|
+
manual() {
|
|
71
|
+
beforeAll(vis$1.beforeAll.setup);
|
|
72
|
+
},
|
|
73
|
+
auto() {
|
|
74
|
+
beforeAll(async () => {
|
|
75
|
+
await vis$1.beforeAll.setup();
|
|
76
|
+
setAutoSnapshotOptions(true);
|
|
77
|
+
});
|
|
78
|
+
afterEach(vis$1.afterEach.matchImageSnapshot);
|
|
79
|
+
},
|
|
80
|
+
theme(themes) {
|
|
81
|
+
beforeAll(async () => {
|
|
82
|
+
await vis$1.beforeAll.setup();
|
|
83
|
+
setAutoSnapshotOptions(true);
|
|
84
|
+
});
|
|
85
|
+
afterEach(vis$1.afterEach.matchPerTheme(themes));
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
beforeAll: { async setup() {
|
|
89
|
+
subject = (await commands$1.setupVisSuite()).subject;
|
|
90
|
+
} },
|
|
91
|
+
afterEach: {
|
|
92
|
+
async matchImageSnapshot() {
|
|
93
|
+
return vis$1.afterEach.matchPerTheme({ async auto() {} })();
|
|
94
|
+
},
|
|
95
|
+
matchPerTheme(themes) {
|
|
96
|
+
return async function matchImageSnapshot() {
|
|
97
|
+
const test = ctx.getCurrentTest();
|
|
98
|
+
if ((test?.result?.errors?.length ?? 0) > 0) return;
|
|
99
|
+
const meta = extractAutoSnapshotOptions(test);
|
|
100
|
+
if (!shouldTakeSnapshot(meta)) return;
|
|
101
|
+
const errors = [];
|
|
102
|
+
for (const themeId in themes) try {
|
|
103
|
+
await new Promise((a) => setTimeout(a, 10));
|
|
104
|
+
const theme = themes[themeId];
|
|
105
|
+
if ((typeof theme === "function" ? await theme(meta) : theme) === false) continue;
|
|
106
|
+
await test.context.expect(getSubject(meta?.subject ?? subject)).toMatchImageSnapshot({
|
|
107
|
+
...meta,
|
|
108
|
+
snapshotKey: meta?.snapshotKey ?? themeId
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
errors.push([themeId, error]);
|
|
112
|
+
}
|
|
113
|
+
if (errors.length > 0) {
|
|
114
|
+
if (errors.length === 1) throw errors[0][1];
|
|
115
|
+
const taskId = toTaskId(test);
|
|
116
|
+
throw new AggregateError(errors, dedent`Snapshot \`${taskId}\` mismatched
|
|
117
|
+
|
|
118
|
+
${errors.map(([themeId, error]) => {
|
|
119
|
+
return `Theme \`${themeId}\` failed: ${error.message}`;
|
|
120
|
+
}).join("\n\n")}`);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return vis$1;
|
|
127
|
+
}
|
|
128
|
+
function getSubject(selectors) {
|
|
129
|
+
return selectors ? document.querySelector(selectors) ?? document.body : document.body;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/client/setup/vis.ts
|
|
134
|
+
/**
|
|
135
|
+
* Visual test configuration on the client side.
|
|
136
|
+
*/
|
|
137
|
+
const vis = createVis(commands);
|
|
138
|
+
|
|
139
|
+
//#endregion
|
|
140
|
+
export { createVis as n, vis as t };
|
|
141
|
+
//# sourceMappingURL=setup-BWgIDtv-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-BWgIDtv-.mjs","names":["toMatchImageSnapshot","subject: string | undefined","vis: VisClientConfigurator<GM>","vis","commands","errors: Array<[string, Error]>"],"sources":["../src/client/expect/to_match_image_snapshot.ts","../src/client/expect/extend.ts","../src/client/page/has_image_snapshot.ts","../src/client/page/to_match_image_snapshot.ts","../src/client/page/extend.ts","../src/client/should_take_snapshot.ts","../src/client/setup/create_vis.ts","../src/client/setup/vis.ts"],"sourcesContent":["import { commands } from 'vitest/browser'\nimport type { AsyncExpectationResult } from '@vitest/expect'\nimport type { ToMatchImageSnapshotOptions } from '../../shared/types.ts'\nimport { matchImageSnapshotAction } from '../actions/match_image_snapshot_action.ts'\nimport { ctx } from '../ctx.ts'\nimport { toTaskId } from '../task_id.ts'\nimport { success } from './expectation_result.ts'\n\nexport function toMatchImageSnapshot(\n\t/**\n\t * The element or locator to take the snapshot of,\n\t * or the base64 value of the image to compare against.\n\t */\n\tsubject: any,\n\toptions?: ToMatchImageSnapshotOptions | undefined,\n): AsyncExpectationResult {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) {\n\t\tthrow new Error('`toMatchImageSnapshot()` must be called in a test.')\n\t}\n\n\tif (test.concurrent) {\n\t\tthrow new Error(\n\t\t\t'`toMatchImageSnapshot()` cannot be called in a concurrent test because ' +\n\t\t\t\t\"concurrent tests run at the same time in the same iframe and affect each other's environment.\",\n\t\t)\n\t}\n\n\treturn matchImageSnapshotAction(commands, toTaskId(test), subject, options).then(() => success)\n}\n","import { expect } from 'vitest'\nimport { toMatchImageSnapshot } from './to_match_image_snapshot.ts'\nimport './augment.ts'\n\nexpect.extend({ toMatchImageSnapshot })\n","import { type BrowserPage, commands } from 'vitest/browser'\nimport type { ImageSnapshotKeyOptions } from '../../shared/types.ts'\nimport { hasImageSnapshotAction } from '../actions/has_image_snapshot_action.ts'\nimport { ctx } from '../ctx.ts'\nimport { toTaskId } from '../task_id.ts'\n\nexport interface HasImageSnapshotAction {\n\t/**\n\t * Check if the snapshot image exists.\n\t */\n\thasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined): Promise<boolean>\n}\n\nexport function hasImageSnapshot(this: BrowserPage, options?: ImageSnapshotKeyOptions | undefined) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) {\n\t\tthrow new Error('`hasImageSnapshot()` must be called in a test.')\n\t}\n\n\tif (test.concurrent) {\n\t\tthrow new Error(\n\t\t\t'`hasImageSnapshot()` cannot be called in a concurrent test because ' +\n\t\t\t\t\"concurrent tests run at the same time in the same iframe and affect each other's environment. \",\n\t\t)\n\t}\n\treturn hasImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import { commands } from 'vitest/browser'\nimport type { ComparisonMethod, ToMatchPageImageSnapshotOptions } from '../../shared/types.ts'\nimport { matchPageImageSnapshotAction } from '../actions/match_page_image_snapshot_action.ts'\nimport { ctx } from '../ctx.ts'\nimport { toTaskId } from '../task_id.ts'\n\nexport interface ToMatchImageSnapshotAction {\n\ttoMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\t\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n\t): Promise<void>\n}\n\nexport function toMatchImageSnapshot<M extends ComparisonMethod = 'pixel'>(\n\toptions?: ToMatchPageImageSnapshotOptions<M> | undefined,\n) {\n\tconst test = ctx.getCurrentTest()\n\tif (!test) {\n\t\tthrow new Error('`toMatchImageSnapshot()` must be called in a test.')\n\t}\n\n\tif (test.concurrent) {\n\t\tthrow new Error(\n\t\t\t'`toMatchImageSnapshot()` cannot be called in a concurrent test because ' +\n\t\t\t\t\"concurrent tests run at the same time in the same iframe and affect each other's environment.\",\n\t\t)\n\t}\n\n\treturn matchPageImageSnapshotAction(commands, toTaskId(test), options)\n}\n","import { page } from 'vitest/browser'\nimport './augment.ts'\nimport { hasImageSnapshot } from './has_image_snapshot.ts'\nimport { toMatchImageSnapshot } from './to_match_image_snapshot.ts'\n\npage.extend({ hasImageSnapshot, toMatchImageSnapshot })\n","import type { SnapshotMeta } from './snapshot_meta.ts'\n\nexport function shouldTakeSnapshot(meta: SnapshotMeta<any> | undefined) {\n\treturn document.body.childElementCount > 0 && meta?.enable\n}\n","import dedent from 'dedent'\nimport { afterEach, beforeAll } from 'vitest'\nimport type { SetupVisSuiteCommand } from '../../server/commands/setup_vis_suite.ts'\nimport type { ComparisonMethod } from '../../shared/types.ts'\nimport { extractAutoSnapshotOptions, setAutoSnapshotOptions } from '../auto_snapshot_options.ts'\nimport { ctx } from '../ctx.ts'\nimport { shouldTakeSnapshot } from '../should_take_snapshot.ts'\nimport type { SnapshotMeta } from '../snapshot_meta.ts'\nimport { toTaskId } from '../task_id.ts'\n\nexport type SetupVisOptions<GM extends Record<string, any> | unknown = unknown> = {\n\tauto?:\n\t\t| boolean\n\t\t| (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\t\toptions: SnapshotMeta<C> & M & GM,\n\t\t ) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t| Record<\n\t\t\t\tstring,\n\t\t\t\t| boolean\n\t\t\t\t| (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\t\t\t\toptions: SnapshotMeta<C> & M & GM,\n\t\t\t\t ) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t >\n}\n\n/**\n * Visual test configuration on the client side.\n */\nexport type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {\n\t/**\n\t * Setup the visual test configuration.\n\t *\n\t * @example\n\t * ```ts\n\t * // Setup with auto snapshot enabled\n\t * vis().setup({ auto: true })\n\t *\n\t * // Setup with auto snapshot disabled\n\t * vis().setup({ auto: false })\n\t *\n\t * // Same as `vis.setup({ auto: false })`\n\t * vis.setup()\n\t *\n\t * // Setup with auto snapshot determined by the test meta\n\t * vis.setup({\n\t * \tauto: async ({ meta }) => meta['darkOnly'],\n\t * })\n\t *\n\t * // Setup with multiple auto snapshots\n\t * vis.setup({\n\t * auto: {\n\t * async light() { document.body.classList.remove('dark') },\n\t * async dark() { document.body.classList.add('dark') },\n\t * }\n\t * })\n\t * ```\n\t */\n\tsetup(options?: SetupVisOptions<GM>): void\n\t/**\n\t * @deprecated Use `vis.setup()` instead.\n\t */\n\tpresets: {\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable visual testing.\n\t\t *\n\t\t * auto snapshot is turned off by default.\n\t\t * You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.\n\t\t */\n\t\tenable(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable visual testing.\n\t\t *\n\t\t * `setAutoSnapshotOptions` will have no effect in this preset.\n\t\t */\n\t\tmanual(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable automatic visual testing.\n\t\t *\n\t\t * This will take a snapshot after each test.\n\t\t */\n\t\tauto(): void\n\t\t/**\n\t\t * @deprecated Use `vis.setup()` instead.\n\t\t *\n\t\t * Enable automatic visual testing with multiple themes.\n\t\t *\n\t\t * This will take a snapshot after each test for each theme.\n\t\t *\n\t\t * @param themes A record of theme names and their setup functions.\n\t\t *\n\t\t * @example\n\t\t * ```ts\n\t\t * vis().presets.theme({\n\t\t * light() { document.body.classList.add('light') },\n\t\t * dark() { document.body.classList.add('dark') },\n\t\t * })\n\t\t * ```\n\t\t */\n\t\ttheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\tthemes: Record<\n\t\t\t\tstring,\n\t\t\t\tboolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t\t>,\n\t\t): void\n\t}\n\tbeforeAll: {\n\t\tsetup(): Promise<void>\n\t}\n\tafterEach: {\n\t\tmatchImageSnapshot(): Promise<void>\n\t\tmatchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(\n\t\t\tthemes: Record<\n\t\t\t\tstring,\n\t\t\t\tboolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)\n\t\t\t>,\n\t\t): () => Promise<void>\n\t}\n}\n\nexport function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand) {\n\tlet subject: string | undefined\n\n\tconst vis: VisClientConfigurator<GM> = {\n\t\tsetup(options) {\n\t\t\tif (!options || options.auto === false) {\n\t\t\t\tbeforeAll(vis.beforeAll.setup)\n\t\t\t} else {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait vis.beforeAll.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tif (typeof options?.auto === 'function') {\n\t\t\t\tafterEach(\n\t\t\t\t\tvis.afterEach.matchPerTheme({\n\t\t\t\t\t\tauto: options.auto,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t} else if (typeof options?.auto === 'object') {\n\t\t\t\tafterEach(vis.afterEach.matchPerTheme(options.auto))\n\t\t\t} else {\n\t\t\t\tafterEach(vis.afterEach.matchImageSnapshot)\n\t\t\t}\n\t\t},\n\t\tpresets: {\n\t\t\tenable() {\n\t\t\t\tbeforeAll(vis.beforeAll.setup)\n\t\t\t\tafterEach(vis.afterEach.matchImageSnapshot)\n\t\t\t},\n\t\t\tmanual() {\n\t\t\t\tbeforeAll(vis.beforeAll.setup)\n\t\t\t},\n\t\t\tauto() {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait vis.beforeAll.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t\tafterEach(vis.afterEach.matchImageSnapshot)\n\t\t\t},\n\t\t\ttheme(themes) {\n\t\t\t\tbeforeAll(async () => {\n\t\t\t\t\tawait vis.beforeAll.setup()\n\t\t\t\t\tsetAutoSnapshotOptions(true)\n\t\t\t\t})\n\t\t\t\tafterEach(vis.afterEach.matchPerTheme(themes))\n\t\t\t},\n\t\t},\n\t\tbeforeAll: {\n\t\t\tasync setup() {\n\t\t\t\tsubject = (await commands.setupVisSuite()).subject\n\t\t\t},\n\t\t},\n\t\tafterEach: {\n\t\t\tasync matchImageSnapshot() {\n\t\t\t\treturn vis.afterEach.matchPerTheme({ async auto() {} })()\n\t\t\t},\n\t\t\tmatchPerTheme(themes) {\n\t\t\t\treturn async function matchImageSnapshot() {\n\t\t\t\t\tconst test = ctx.getCurrentTest()\n\t\t\t\t\tif ((test?.result?.errors?.length ?? 0) > 0) return\n\n\t\t\t\t\tconst meta = extractAutoSnapshotOptions(test)\n\t\t\t\t\tif (!shouldTakeSnapshot(meta)) return\n\t\t\t\t\tconst errors: Array<[string, Error]> = []\n\t\t\t\t\tfor (const themeId in themes) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait new Promise((a) => setTimeout(a, 10))\n\t\t\t\t\t\t\tconst theme = themes[themeId]\n\t\t\t\t\t\t\tconst r = typeof theme === 'function' ? await theme(meta! as any) : theme\n\t\t\t\t\t\t\tif (r === false) continue\n\t\t\t\t\t\t\tawait test!.context.expect(getSubject(meta?.subject ?? subject)).toMatchImageSnapshot({\n\t\t\t\t\t\t\t\t...meta,\n\t\t\t\t\t\t\t\tsnapshotKey: meta?.snapshotKey ?? themeId,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\terrors.push([themeId, error as Error])\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (errors.length > 0) {\n\t\t\t\t\t\tif (errors.length === 1) throw errors[0]![1]\n\t\t\t\t\t\tconst taskId = toTaskId(test!)\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\terrors,\n\t\t\t\t\t\t\tdedent`Snapshot \\`${taskId}\\` mismatched\n\n\t\t\t\t\t\t${errors\n\t\t\t\t\t\t\t.map(([themeId, error]) => {\n\t\t\t\t\t\t\t\treturn `Theme \\`${themeId}\\` failed: ${error.message}`\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join('\\n\\n')}`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t}\n\treturn vis\n}\n\nfunction getSubject(selectors: string | undefined) {\n\treturn selectors ? (document.querySelector(selectors) ?? document.body) : document.body\n}\n","import { commands } from 'vitest/browser'\nimport { createVis } from './create_vis.ts'\n\n/**\n * Visual test configuration on the client side.\n */\nexport const vis = createVis(commands)\n"],"mappings":"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"}
|
package/dist/setup.d.mts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { n as ComparisonMethod, x as SnapshotMeta } from "./types-DFb23VE1.mjs";
|
|
2
|
+
import "./vis_server_context.types-Ce1f9vOO.mjs";
|
|
3
|
+
import "./types-Do1N7g4c.mjs";
|
|
4
|
+
import { t as SetupVisSuiteCommand } from "./setup_vis_suite-C6JGGT7B.mjs";
|
|
5
|
+
import "./to_match_image_snapshot.types-p-zilA_M.mjs";
|
|
6
|
+
import "./augment-BJmy1S7i.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/client/setup/create_vis.d.ts
|
|
9
|
+
type SetupVisOptions<GM extends Record<string, any> | unknown = unknown> = {
|
|
10
|
+
auto?: boolean | (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void) | Record<string, boolean | (<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Visual test configuration on the client side.
|
|
14
|
+
*/
|
|
15
|
+
type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {
|
|
16
|
+
/**
|
|
17
|
+
* Setup the visual test configuration.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* // Setup with auto snapshot enabled
|
|
22
|
+
* vis().setup({ auto: true })
|
|
23
|
+
*
|
|
24
|
+
* // Setup with auto snapshot disabled
|
|
25
|
+
* vis().setup({ auto: false })
|
|
26
|
+
*
|
|
27
|
+
* // Same as `vis.setup({ auto: false })`
|
|
28
|
+
* vis.setup()
|
|
29
|
+
*
|
|
30
|
+
* // Setup with auto snapshot determined by the test meta
|
|
31
|
+
* vis.setup({
|
|
32
|
+
* auto: async ({ meta }) => meta['darkOnly'],
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* // Setup with multiple auto snapshots
|
|
36
|
+
* vis.setup({
|
|
37
|
+
* auto: {
|
|
38
|
+
* async light() { document.body.classList.remove('dark') },
|
|
39
|
+
* async dark() { document.body.classList.add('dark') },
|
|
40
|
+
* }
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
setup(options?: SetupVisOptions<GM>): void;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Use `vis.setup()` instead.
|
|
47
|
+
*/
|
|
48
|
+
presets: {
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `vis.setup()` instead.
|
|
51
|
+
*
|
|
52
|
+
* Enable visual testing.
|
|
53
|
+
*
|
|
54
|
+
* auto snapshot is turned off by default.
|
|
55
|
+
* You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.
|
|
56
|
+
*/
|
|
57
|
+
enable(): void;
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Use `vis.setup()` instead.
|
|
60
|
+
*
|
|
61
|
+
* Enable visual testing.
|
|
62
|
+
*
|
|
63
|
+
* `setAutoSnapshotOptions` will have no effect in this preset.
|
|
64
|
+
*/
|
|
65
|
+
manual(): void;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated Use `vis.setup()` instead.
|
|
68
|
+
*
|
|
69
|
+
* Enable automatic visual testing.
|
|
70
|
+
*
|
|
71
|
+
* This will take a snapshot after each test.
|
|
72
|
+
*/
|
|
73
|
+
auto(): void;
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated Use `vis.setup()` instead.
|
|
76
|
+
*
|
|
77
|
+
* Enable automatic visual testing with multiple themes.
|
|
78
|
+
*
|
|
79
|
+
* This will take a snapshot after each test for each theme.
|
|
80
|
+
*
|
|
81
|
+
* @param themes A record of theme names and their setup functions.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* vis().presets.theme({
|
|
86
|
+
* light() { document.body.classList.add('light') },
|
|
87
|
+
* dark() { document.body.classList.add('dark') },
|
|
88
|
+
* })
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
theme<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)>): void;
|
|
92
|
+
};
|
|
93
|
+
beforeAll: {
|
|
94
|
+
setup(): Promise<void>;
|
|
95
|
+
};
|
|
96
|
+
afterEach: {
|
|
97
|
+
matchImageSnapshot(): Promise<void>;
|
|
98
|
+
matchPerTheme<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>;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
declare function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand): VisClientConfigurator<GM>;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/client/setup/vis.d.ts
|
|
104
|
+
/**
|
|
105
|
+
* Visual test configuration on the client side.
|
|
106
|
+
*/
|
|
107
|
+
declare const vis: VisClientConfigurator<unknown>;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { SetupVisOptions, VisClientConfigurator, createVis, vis };
|
|
110
|
+
//# sourceMappingURL=setup.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.mts","names":[],"sources":["../src/client/setup/create_vis.ts","../src/client/setup/vis.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAUY,2BAA2B;+BAGvB,4BAA4B,kDAC/B,aAAa,KAAK,IAAI,OAC1B,mBAAmB,kCACxB,qCAGc,4BAA4B,kDAC/B,aAAa,KAAK,IAAI,OAC1B,mBAAmB;;;;AAX9B;AAAuC,KAkB3B,qBAlB2B,CAAA,WAkBM,MAlBN,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,OAAA,GAAA,OAAA,CAAA,GAAA;EAGvB;;;;;;;;;;;;;;;;;;AAehB;;;;;;;;;;EA+EsD,KAAA,CAAA,OAAA,CAAA,EAlDrC,eAkDqC,CAlDrB,EAkDqB,CAAA,CAAA,EAAA,IAAA;EAAmB;;;EAQjD,OAAA,EAAA;IACE;;;;;;;;IACf,MAAA,EAAA,EAAA,IAAA;IAIA;;AAIX;;;;;IAA4G,MAAA,EAAA,EAAA,IAAA;;;;ACvH5G;;;;;;;;;;;;;;;;;;;;;;oBDkGkB,4BAA4B,iDACnC,oCAEc,aAAa,KAAK,IAAI,OAAO,mBAAmB;;;aAK9D;;;0BAGa;4BACE,4BAA4B,iDAC3C,oCAEc,aAAa,KAAK,IAAI,OAAO,mBAAmB,yCAE9D;;;iBAIK,qBAAqB,mDAAmD,uBAAoB,sBAAA;;;;;;cCvH/F,KAAyB"}
|
package/dist/setup.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "./asserts--HSSlgPD.mjs";
|
|
2
|
+
import "./constants-CTBaz8Ml.mjs";
|
|
3
|
+
import "./auto_snapshot_options-CAD43Zkp.mjs";
|
|
4
|
+
import "./base64-CHSENEAO.mjs";
|
|
5
|
+
import "./task_id-DnS9_4Ub.mjs";
|
|
6
|
+
import { n as createVis, t as vis } from "./setup-BWgIDtv-.mjs";
|
|
7
|
+
|
|
8
|
+
export { createVis, vis };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { t as VisOptions } from "./types-Do1N7g4c.mjs";
|
|
2
|
+
import { Pick } from "type-plus";
|
|
3
|
+
|
|
4
|
+
//#region src/server/commands/setup_vis_suite.d.ts
|
|
5
|
+
interface SetupVisSuiteCommand {
|
|
6
|
+
/**
|
|
7
|
+
* Sets up the visual testing suite by cleaning up previous snapshot and diff output directories.
|
|
8
|
+
* When this command is run for the first time,
|
|
9
|
+
* it will remove the results and diffs directory of all suites.
|
|
10
|
+
*
|
|
11
|
+
* In subsequent runs, it will only remove the results and diffs directory of the current suite.
|
|
12
|
+
*/
|
|
13
|
+
setupVisSuite: () => Promise<Pick<VisOptions, 'comparisonMethod' | 'diffOptions' | 'failureThreshold' | 'failureThresholdType' | 'snapshotKey' | 'subject' | 'timeout'>>;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { SetupVisSuiteCommand as t };
|
|
17
|
+
//# sourceMappingURL=setup_vis_suite-C6JGGT7B.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup_vis_suite-C6JGGT7B.d.mts","names":[],"sources":["../src/server/commands/setup_vis_suite.ts"],"sourcesContent":[],"mappings":";;;;UAMiB,oBAAA;EAAA;;;;;;;uBAQK,QACpB,KACC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { a as SNAPSHOT_ROOT_DIR } from "./constants-CTBaz8Ml.mjs";
|
|
2
|
+
import ci from "is-ci";
|
|
3
|
+
import { platform } from "node:process";
|
|
4
|
+
|
|
5
|
+
//#region src/shared/trim_common_folder.ts
|
|
6
|
+
/**
|
|
7
|
+
* Trim off common folder such as `src` or `tests` from the test file path.
|
|
8
|
+
* This is used to generate the default snapshot sub-path.
|
|
9
|
+
*/
|
|
10
|
+
function trimCommonFolder(suiteName) {
|
|
11
|
+
suiteName = suiteName.replaceAll("..", "__");
|
|
12
|
+
const suiteDir = suiteName.split("/", 1)[0];
|
|
13
|
+
if ([
|
|
14
|
+
"tests",
|
|
15
|
+
"test",
|
|
16
|
+
"src",
|
|
17
|
+
"source",
|
|
18
|
+
"js",
|
|
19
|
+
"ts",
|
|
20
|
+
"lib"
|
|
21
|
+
].includes(suiteDir)) return suiteName.slice(suiteDir.length + 1);
|
|
22
|
+
return suiteName;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/server/snapshot_path.ts
|
|
27
|
+
function resolveSnapshotRootDir(browserCommandContext, options) {
|
|
28
|
+
if (!options.snapshotRootDir) return getSnapshotRootDir(SNAPSHOT_ROOT_DIR);
|
|
29
|
+
const snapshotRootDir = options.snapshotRootDir;
|
|
30
|
+
if (typeof snapshotRootDir === "string") return getSnapshotRootDir(snapshotRootDir);
|
|
31
|
+
const { config } = browserCommandContext.project.browser;
|
|
32
|
+
return snapshotRootDir({
|
|
33
|
+
ci,
|
|
34
|
+
browserName: config.browser.name,
|
|
35
|
+
providerName: browserCommandContext.provider.name,
|
|
36
|
+
platform,
|
|
37
|
+
screenshotFailures: config.browser.screenshotFailures,
|
|
38
|
+
screenshotDirectory: config.browser.screenshotDirectory
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the root directory for storing snapshots.
|
|
43
|
+
*
|
|
44
|
+
* @param snapshotRootDir - Base directory for snapshots. Defaults to `__vis__`.
|
|
45
|
+
* @returns The full snapshot root directory path, which includes a platform-specific subdirectory:
|
|
46
|
+
* - When running in CI: `<snapshotRootDir>/<platform>` (e.g. `__vis__/linux`)
|
|
47
|
+
* - When running locally: `<snapshotRootDir>/local`
|
|
48
|
+
*/
|
|
49
|
+
function getSnapshotRootDir(snapshotRootDir = SNAPSHOT_ROOT_DIR) {
|
|
50
|
+
return `${snapshotRootDir}/${ci ? platform : "local"}`;
|
|
51
|
+
}
|
|
52
|
+
function getSnapshotSubpath(suiteName, options) {
|
|
53
|
+
return (options.snapshotSubpath ?? (({ subpath }) => trimCommonFolder(subpath)))({ subpath: suiteName });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { trimCommonFolder as i, getSnapshotSubpath as n, resolveSnapshotRootDir as r, getSnapshotRootDir as t };
|
|
58
|
+
//# sourceMappingURL=snapshot_path-7GliOSH_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot_path-7GliOSH_.mjs","names":[],"sources":["../src/shared/trim_common_folder.ts","../src/server/snapshot_path.ts"],"sourcesContent":["/**\n * Trim off common folder such as `src` or `tests` from the test file path.\n * This is used to generate the default snapshot sub-path.\n */\nexport function trimCommonFolder(suiteName: string) {\n\tsuiteName = suiteName.replaceAll('..', '__')\n\tconst suiteDir = suiteName.split('/', 1)[0]!\n\tif (['tests', 'test', 'src', 'source', 'js', 'ts', 'lib'].includes(suiteDir))\n\t\treturn suiteName.slice(suiteDir.length + 1)\n\treturn suiteName\n}\n","import ci from 'is-ci'\nimport { platform } from 'node:process'\nimport type { VisOptions } from '../config/types.ts'\nimport { SNAPSHOT_ROOT_DIR } from '../shared/constants.ts'\nimport { trimCommonFolder } from '../shared/trim_common_folder.ts'\nimport type { ExtendedBrowserCommandContext } from './vis_server_context.types.ts'\n\nexport function resolveSnapshotRootDir(browserCommandContext: ExtendedBrowserCommandContext, options: VisOptions) {\n\tif (!options.snapshotRootDir) return getSnapshotRootDir(SNAPSHOT_ROOT_DIR)\n\tconst snapshotRootDir = options.snapshotRootDir\n\tif (typeof snapshotRootDir === 'string') return getSnapshotRootDir(snapshotRootDir)\n\tconst { config } = browserCommandContext.project.browser\n\treturn snapshotRootDir({\n\t\tci,\n\t\tbrowserName: config.browser.name,\n\t\tproviderName: browserCommandContext.provider.name,\n\t\tplatform,\n\t\tscreenshotFailures: config.browser.screenshotFailures,\n\t\tscreenshotDirectory: config.browser.screenshotDirectory,\n\t})\n}\n\n/**\n * Gets the root directory for storing snapshots.\n *\n * @param snapshotRootDir - Base directory for snapshots. Defaults to `__vis__`.\n * @returns The full snapshot root directory path, which includes a platform-specific subdirectory:\n * - When running in CI: `<snapshotRootDir>/<platform>` (e.g. `__vis__/linux`)\n * - When running locally: `<snapshotRootDir>/local`\n */\nexport function getSnapshotRootDir(snapshotRootDir = SNAPSHOT_ROOT_DIR) {\n\treturn `${snapshotRootDir}/${ci ? platform : 'local'}`\n}\n\nexport function getSnapshotSubpath(suiteName: string, options: Pick<VisOptions, 'snapshotSubpath'>) {\n\tconst snapshotSubpath = options.snapshotSubpath ?? (({ subpath }) => trimCommonFolder(subpath))\n\treturn snapshotSubpath({ subpath: suiteName })\n}\n"],"mappings":";;;;;;;;;AAIA,SAAgB,iBAAiB,WAAmB;AACnD,aAAY,UAAU,WAAW,MAAM,KAAK;CAC5C,MAAM,WAAW,UAAU,MAAM,KAAK,EAAE,CAAC;AACzC,KAAI;EAAC;EAAS;EAAQ;EAAO;EAAU;EAAM;EAAM;EAAM,CAAC,SAAS,SAAS,CAC3E,QAAO,UAAU,MAAM,SAAS,SAAS,EAAE;AAC5C,QAAO;;;;;ACFR,SAAgB,uBAAuB,uBAAsD,SAAqB;AACjH,KAAI,CAAC,QAAQ,gBAAiB,QAAO,mBAAmB,kBAAkB;CAC1E,MAAM,kBAAkB,QAAQ;AAChC,KAAI,OAAO,oBAAoB,SAAU,QAAO,mBAAmB,gBAAgB;CACnF,MAAM,EAAE,WAAW,sBAAsB,QAAQ;AACjD,QAAO,gBAAgB;EACtB;EACA,aAAa,OAAO,QAAQ;EAC5B,cAAc,sBAAsB,SAAS;EAC7C;EACA,oBAAoB,OAAO,QAAQ;EACnC,qBAAqB,OAAO,QAAQ;EACpC,CAAC;;;;;;;;;;AAWH,SAAgB,mBAAmB,kBAAkB,mBAAmB;AACvE,QAAO,GAAG,gBAAgB,GAAG,KAAK,WAAW;;AAG9C,SAAgB,mBAAmB,WAAmB,SAA8C;AAEnG,SADwB,QAAQ,qBAAqB,EAAE,cAAc,iBAAiB,QAAQ,GACvE,EAAE,SAAS,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|