@vickbk/tests 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2026-10-24
11
+
12
+ ### Added
13
+
14
+ - Shared text-pattern utilities and types, including `patternToRegex`, `LABEL_LOCATOR`, `TEXT_MATCHER`, `TEXT_PATTERN`, and `TEXT_WITH_NTH` through `@vickbk/tests`.
15
+ - Vitest utilities for DOM assertions, console controls, user interactions, promise helpers, and toggle-event handling through `@vickbk/tests/vitest`.
16
+ - React Server Component tree resolution through `@vickbk/tests/react`.
17
+ - Playwright utilities for assertions, locators, interactions, and reusable test execution through `@vickbk/tests/playwright`.
18
+ - Public package entrypoints for shared helpers, Vitest utilities, React utilities, and Playwright utilities.
19
+ - TypeScript declaration files for the published entrypoints.
20
+ - ESM and CommonJS builds for supported entrypoints, with the `@vickbk/tests/vitest` entrypoint published as ESM-only.
21
+ - Package documentation covering installation, peer dependencies, setup, and API usage.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vick Bake
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,192 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @vickbk/tests
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@vickbk/tests.svg)](https://www.npmjs.com/package/@vickbk/tests)
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/vickbk/tests/lint-test-docs.yml?branch=main)](https://github.com/vickbk/tests/actions)
6
+ [![Test Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/vickbk/tests)
7
+
8
+ Reusable testing utilities for TypeScript projects: framework-agnostic shared
9
+ helpers, a collection of Vitest utilities, React Server Component helpers, and
10
+ a Playwright DSL. Import only the entrypoint that matches the testing tools
11
+ and integrations used by your project.
12
+
13
+ ## Overview
14
+
15
+ The package is organized around stable public entrypoints:
16
+
17
+ - Shared text-pattern helpers and types are available from the package root.
18
+ - Vitest utilities provide DOM assertions and interactions, console controls,
19
+ promise helpers, and a package-provided toggle-event helper.
20
+ - React utilities provide React Server Component (RSC) tree resolution.
21
+ - Playwright utilities provide assertions, locators, interactions, and a
22
+ reusable runner.
23
+
24
+ ## Installation
25
+
26
+ Install the package as a development dependency:
27
+
28
+ ```sh
29
+ pnpm add -D @vickbk/tests
30
+ ```
31
+
32
+ The integrations are optional peer dependencies. Add the peers needed by your
33
+ project; for Vitest DOM tests, for example:
34
+
35
+ ```sh
36
+ pnpm add -D vitest jsdom @testing-library/react @testing-library/user-event @testing-library/jest-dom
37
+ ```
38
+
39
+ For Playwright tests, install `@playwright/test`. For React Server Component
40
+ helpers, install `react` and `react-dom` (and `@types/react` when using
41
+ TypeScript).
42
+
43
+ ## Public entrypoints
44
+
45
+ | Import path | Purpose |
46
+ | -------------------------- | --------------------------------------------------------- |
47
+ | `@vickbk/tests` | Shared text-pattern utilities and types |
48
+ | `@vickbk/tests/vitest` | Vitest console, DOM, promise, and toggle-event helpers |
49
+ | `@vickbk/tests/react` | React Server Component tree resolution |
50
+ | `@vickbk/tests/playwright` | Playwright assertions, locators, interactions, and runner |
51
+
52
+ **Module format:** The `@vickbk/tests/vitest` entrypoint is ESM-only. Use
53
+ `import` to consume it; CommonJS `require()` is not supported. The other
54
+ entrypoints retain their existing module-format support.
55
+
56
+ ## Shared text-pattern helpers
57
+
58
+ The shared API provides `patternToRegex` and the `LABEL_LOCATOR`,
59
+ `TEXT_MATCHER`, `TEXT_PATTERN`, and `TEXT_WITH_NTH` types.
60
+
61
+ ```ts
62
+ import { patternToRegex, type TEXT_MATCHER } from "@vickbk/tests";
63
+
64
+ const matcher: TEXT_MATCHER = ["Welcome", 0];
65
+ const caseInsensitive = patternToRegex("Welcome");
66
+ ```
67
+
68
+ ## Vitest setup
69
+
70
+ The package supports Node.js 20 and newer. Its peer dependency ranges are:
71
+
72
+ | Peer dependency | Supported range | Used for |
73
+ | ----------------------------- | ---------------------- | ----------------------------------------------------- |
74
+ | `vitest` | `^5.0.4` | Vitest helpers |
75
+ | `@testing-library/react` | `^16.0.0` | DOM queries, interactions, and toggle events |
76
+ | `@testing-library/user-event` | `^14.6.8` | User-like DOM interactions |
77
+ | `@testing-library/jest-dom` | `^7.0.1` | DOM matcher setup used by the DOM assertion helpers |
78
+ | `@playwright/test` | `^1.64.0` | Playwright helpers and direct `test`/`expect` exports |
79
+ | `react`, `react-dom` | `^18.0.0` or `^19.0.0` | React integrations and RSC helpers |
80
+ | `@types/react` | `^18.0.0` or `^19.0.0` | React TypeScript types |
81
+
82
+ All peers are optional at the package level. Install the peers for the
83
+ entrypoints your project imports.
84
+
85
+ Configure Vitest to use a DOM environment for DOM tests, and load the
86
+ jest-dom Vitest matchers from a setup file:
87
+
88
+ ```ts
89
+ // vitest.config.ts
90
+ import { defineConfig } from "vitest/config";
91
+
92
+ export default defineConfig({
93
+ test: {
94
+ environment: "jsdom",
95
+ setupFiles: ["./tests/setup.ts"],
96
+ },
97
+ });
98
+ ```
99
+
100
+ ```ts
101
+ // tests/setup.ts
102
+ import "@testing-library/jest-dom/vitest";
103
+ ```
104
+
105
+ ## Vitest utilities
106
+
107
+ Import DOM helpers and console controls from `@vickbk/tests/vitest`.
108
+ `shouldSee` returns the matched elements, while `shouldHaveTestId` returns the
109
+ elements located by test ID.
110
+
111
+ ```tsx
112
+ import { render } from "@testing-library/react";
113
+ import { shouldHaveTestId, shouldSee } from "@vickbk/tests/vitest";
114
+
115
+ render(
116
+ <main>
117
+ <h1>Welcome</h1>
118
+ <button data-testid="save-button">Save</button>
119
+ </main>,
120
+ );
121
+
122
+ const [heading] = shouldSee("Welcome");
123
+ const [saveButton] = shouldHaveTestId("save-button");
124
+ ```
125
+
126
+ To suppress console output during a test, pair `shutConsole` with
127
+ `resetConsole`:
128
+
129
+ ```ts
130
+ import { afterEach, beforeEach } from "vitest";
131
+ import { resetConsole, shutConsole } from "@vickbk/tests/vitest";
132
+
133
+ beforeEach(shutConsole);
134
+ afterEach(resetConsole);
135
+ ```
136
+
137
+ The Vitest entrypoint provides its own `fireEvent`, combining standard Testing
138
+ Library event helpers with `toggle`. Import it directly; no separate toggle
139
+ installation is needed:
140
+
141
+ ```ts
142
+ import { fireEvent } from "@vickbk/tests/vitest";
143
+
144
+ fireEvent.click(document.body);
145
+ fireEvent.toggle(document.body);
146
+ ```
147
+
148
+ The Vitest entrypoint also exports `shouldNotSee`, `isChecked`,
149
+ `isNotChecked`, `shouldHaveAttributes`, `shouldNotHaveTestId`, `userClicks`,
150
+ `userTypes`, `userTypesMultiple`, `togglePopover`, `resolvedPromise`, and
151
+ `rejectedPromise`.
152
+
153
+ [For more details on Vitest API](./src/features/vitest/README.md)
154
+
155
+ ## React utilities
156
+
157
+ The React entrypoint exposes `resolveRscTree`:
158
+
159
+ ```tsx
160
+ import { resolveRscTree } from "@vickbk/tests/react";
161
+
162
+ const resolved = await resolveRscTree(<ServerPage />);
163
+ ```
164
+
165
+ [For more on React API](./src/features/react/README.md)
166
+
167
+ ## Playwright utilities
168
+
169
+ Playwright helpers are imported from `@vickbk/tests/playwright`.
170
+
171
+ ```ts
172
+ import { expect, test } from "@playwright/test";
173
+ import { clickButton, getButton, shouldSee } from "@vickbk/tests/playwright";
174
+
175
+ test("saves the page", async ({ page }) => {
176
+ await page.goto("/");
177
+ await shouldSee(page, "Welcome");
178
+ await clickButton(page, "Save");
179
+ await expect(getButton(page, "Save")).toBeVisible();
180
+ });
181
+ ```
182
+
183
+ The public API also includes `shouldNotSee`, `isChecked`, `isNotChecked`,
184
+ `getLocatorByText`, `getLabel`, `getLink`, `fillLocatorWith`,
185
+ `setLocatorValue`, `setValueForLocators`, `clickLink`, `clickLabelInput`,
186
+ `clickMultipleLabelInputs`, `clickBodyCorner`, and `runSimilarTests`.
187
+
188
+ [For more details on the Playwright API](./src/features/playwright/README.md)
189
+
190
+ ## License
191
+
192
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_pattern_to_regex = require("./pattern-to-regex-BrMJtzu8.cjs");
3
+ exports.patternToRegex = require_pattern_to_regex.patternToRegex;
@@ -0,0 +1,6 @@
1
+ import { i as TEXT_WITH_NTH, n as TEXT_MATCHER, r as TEXT_PATTERN, t as LABEL_LOCATOR } from "./types-BlSFP07Z.cjs";
2
+ //#region src/shared/regex/utils/pattern-to-regex.d.ts
3
+ export declare function patternToRegex(target: TEXT_PATTERN, flags?: string): RegExp;
4
+ //#endregion
5
+ export type { LABEL_LOCATOR, TEXT_MATCHER, TEXT_PATTERN, TEXT_WITH_NTH };
6
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/shared/regex/utils/pattern-to-regex.ts"],"mappings":";;wBAGgB,eACd,QAAQ,cACR,iBACC"}
@@ -0,0 +1,6 @@
1
+ import { i as TEXT_WITH_NTH, n as TEXT_MATCHER, r as TEXT_PATTERN, t as LABEL_LOCATOR } from "./types-BlSFP07Z.mjs";
2
+ //#region src/shared/regex/utils/pattern-to-regex.d.ts
3
+ export declare function patternToRegex(target: TEXT_PATTERN, flags?: string): RegExp;
4
+ //#endregion
5
+ export type { LABEL_LOCATOR, TEXT_MATCHER, TEXT_PATTERN, TEXT_WITH_NTH };
6
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/shared/regex/utils/pattern-to-regex.ts"],"mappings":";;wBAGgB,eACd,QAAQ,cACR,iBACC"}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { t as patternToRegex } from "./pattern-to-regex-CO5Y0oDU.mjs";
@@ -0,0 +1,19 @@
1
+ //#region src/shared/regex/utils/escape-regex.ts
2
+ function escapeRegExp(str) {
3
+ if (typeof RegExp.escape === "function") return RegExp.escape(str);
4
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ }
6
+ //#endregion
7
+ //#region src/shared/regex/utils/pattern-to-regex.ts
8
+ function patternToRegex(target, flags = "i") {
9
+ return typeof target === "string" ? new RegExp(escapeRegExp(target), flags) : target;
10
+ }
11
+ //#endregion
12
+ Object.defineProperty(exports, "patternToRegex", {
13
+ enumerable: true,
14
+ get: function() {
15
+ return patternToRegex;
16
+ }
17
+ });
18
+
19
+ //# sourceMappingURL=pattern-to-regex-BrMJtzu8.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-to-regex-BrMJtzu8.cjs","names":[],"sources":["../src/shared/regex/utils/escape-regex.ts","../src/shared/regex/utils/pattern-to-regex.ts"],"sourcesContent":["export function escapeRegExp(str: string): string {\r\n if (typeof RegExp.escape === \"function\") {\r\n return RegExp.escape(str);\r\n }\r\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\r\n}\r\n","import { TEXT_PATTERN } from \"../types\";\r\nimport { escapeRegExp } from \"./escape-regex\";\r\n\r\nexport function patternToRegex(\r\n target: TEXT_PATTERN,\r\n flags: string = \"i\",\r\n): RegExp {\r\n return typeof target === \"string\"\r\n ? new RegExp(escapeRegExp(target), flags)\r\n : target;\r\n}\r\n"],"mappings":";AAAA,SAAgB,aAAa,KAAqB;CAChD,IAAI,OAAO,OAAO,WAAW,YAC3B,OAAO,OAAO,OAAO,GAAG;CAE1B,OAAO,IAAI,QAAQ,uBAAuB,MAAM;AAClD;;;ACFA,SAAgB,eACd,QACA,QAAgB,KACR;CACR,OAAO,OAAO,WAAW,WACrB,IAAI,OAAO,aAAa,MAAM,GAAG,KAAK,IACtC;AACN"}
@@ -0,0 +1,14 @@
1
+ //#region src/shared/regex/utils/escape-regex.ts
2
+ function escapeRegExp(str) {
3
+ if (typeof RegExp.escape === "function") return RegExp.escape(str);
4
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
+ }
6
+ //#endregion
7
+ //#region src/shared/regex/utils/pattern-to-regex.ts
8
+ function patternToRegex(target, flags = "i") {
9
+ return typeof target === "string" ? new RegExp(escapeRegExp(target), flags) : target;
10
+ }
11
+ //#endregion
12
+ export { patternToRegex as t };
13
+
14
+ //# sourceMappingURL=pattern-to-regex-CO5Y0oDU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern-to-regex-CO5Y0oDU.mjs","names":[],"sources":["../src/shared/regex/utils/escape-regex.ts","../src/shared/regex/utils/pattern-to-regex.ts"],"sourcesContent":["export function escapeRegExp(str: string): string {\r\n if (typeof RegExp.escape === \"function\") {\r\n return RegExp.escape(str);\r\n }\r\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\r\n}\r\n","import { TEXT_PATTERN } from \"../types\";\r\nimport { escapeRegExp } from \"./escape-regex\";\r\n\r\nexport function patternToRegex(\r\n target: TEXT_PATTERN,\r\n flags: string = \"i\",\r\n): RegExp {\r\n return typeof target === \"string\"\r\n ? new RegExp(escapeRegExp(target), flags)\r\n : target;\r\n}\r\n"],"mappings":";AAAA,SAAgB,aAAa,KAAqB;CAChD,IAAI,OAAO,OAAO,WAAW,YAC3B,OAAO,OAAO,OAAO,GAAG;CAE1B,OAAO,IAAI,QAAQ,uBAAuB,MAAM;AAClD;;;ACFA,SAAgB,eACd,QACA,QAAgB,KACR;CACR,OAAO,OAAO,WAAW,WACrB,IAAI,OAAO,aAAa,MAAM,GAAG,KAAK,IACtC;AACN"}
@@ -0,0 +1,327 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.cjs");
3
+ const require_pattern_to_regex = require("./pattern-to-regex-BrMJtzu8.cjs");
4
+ let _playwright_test = require("@playwright/test");
5
+ _playwright_test = require_rolldown_runtime.__toESM(_playwright_test, 1);
6
+ //#region src/features/playwright/modules/assertions/utils/isChecked.ts
7
+ /**
8
+ * Asserts that the element selected by the CSS selector is checked.
9
+ *
10
+ * @param page The Playwright page to search.
11
+ * @param selector CSS selector for a checkbox or radio input.
12
+ * @returns The checked locator.
13
+ * @example
14
+ * ```ts
15
+ * const checkbox = await isChecked(page, "#terms");
16
+ * ```
17
+ */
18
+ async function isChecked(page, selector) {
19
+ const locator = page.locator(selector);
20
+ await (0, _playwright_test.expect)(locator).toBeChecked();
21
+ return locator;
22
+ }
23
+ //#endregion
24
+ //#region src/features/playwright/modules/assertions/utils/isNotChecked.ts
25
+ /**
26
+ * Asserts that the element selected by the CSS selector is not checked.
27
+ *
28
+ * @param page The Playwright page to search.
29
+ * @param selector CSS selector for a checkbox or radio input.
30
+ * @returns The unchecked locator.
31
+ * @example
32
+ * ```ts
33
+ * const checkbox = await isNotChecked(page, "#terms");
34
+ * ```
35
+ */
36
+ async function isNotChecked(page, selector) {
37
+ const locator = page.locator(selector);
38
+ await (0, _playwright_test.expect)(locator).not.toBeChecked();
39
+ return locator;
40
+ }
41
+ //#endregion
42
+ //#region src/features/playwright/modules/assertions/utils/getMatcher.ts
43
+ function getMatcher(page, ...textes) {
44
+ return textes.map((text) => {
45
+ if (Array.isArray(text)) {
46
+ const [matcher, nth] = text;
47
+ return (0, _playwright_test.expect)(page.getByText(require_pattern_to_regex.patternToRegex(matcher)).nth(nth));
48
+ }
49
+ return (0, _playwright_test.expect)(page.getByText(text));
50
+ });
51
+ }
52
+ //#endregion
53
+ //#region src/features/playwright/modules/assertions/utils/shouldNotSee.ts
54
+ /**
55
+ * Asserts that each text matcher is not visible on the page.
56
+ *
57
+ * @param page The Playwright page to inspect.
58
+ * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
59
+ * @returns A promise that resolves when every matching element is not visible.
60
+ * @example
61
+ * ```ts
62
+ * await shouldNotSee(page, "Error message");
63
+ * ```
64
+ */
65
+ async function shouldNotSee(page, ...textes) {
66
+ const matchers = getMatcher(page, ...textes);
67
+ for (let i = 0; i < matchers.length; i++) await matchers[i].not.toBeVisible();
68
+ }
69
+ //#endregion
70
+ //#region src/features/playwright/modules/assertions/utils/shouldSee.ts
71
+ /**
72
+ * Asserts that each text matcher is visible on the page.
73
+ *
74
+ * @param page The Playwright page to inspect.
75
+ * @param textes Text strings, regular expressions, or `[matcher, occurrenceIndex]` pairs.
76
+ * @returns A promise that resolves when every matching element is visible.
77
+ * @example
78
+ * ```ts
79
+ * await shouldSee(page, "Welcome", [/Saved/i, 0]);
80
+ * ```
81
+ */
82
+ async function shouldSee(page, ...textes) {
83
+ const matchers = getMatcher(page, ...textes);
84
+ for (let i = 0; i < matchers.length; i++) await matchers[i].toBeVisible();
85
+ }
86
+ //#endregion
87
+ //#region src/features/playwright/modules/interactions/utils/clickBodyCorner.ts
88
+ /**
89
+ * Clicks the top-left corner of the page body.
90
+ *
91
+ * @param page The Playwright page to interact with.
92
+ * @returns A promise that resolves after the click.
93
+ * @example
94
+ * ```ts
95
+ * await clickBodyCorner(page);
96
+ * ```
97
+ */
98
+ async function clickBodyCorner(page) {
99
+ await page.locator("body").click({ position: {
100
+ x: 0,
101
+ y: 0
102
+ } });
103
+ }
104
+ //#endregion
105
+ //#region src/features/playwright/shared/locators/utils/getLocatorByText.ts
106
+ /**
107
+ * Locates elements matching a selector and text pattern.
108
+ *
109
+ * @param page The Playwright page to search.
110
+ * @param locator Selector paired with text that the element must contain.
111
+ * @returns A locator matching the selector and text.
112
+ * @example
113
+ * ```ts
114
+ * const save = getLocatorByText(page, ["button", "Save"]);
115
+ * ```
116
+ */
117
+ function getLocatorByText(page, [locator, hasText]) {
118
+ return page.locator(locator, { hasText });
119
+ }
120
+ //#endregion
121
+ //#region src/features/playwright/shared/locators/utils/getButton.ts
122
+ /**
123
+ * Locates a button by its contained text.
124
+ *
125
+ * @param page The Playwright page to search.
126
+ * @param hasText Text or regular expression contained by the button.
127
+ * @returns A locator for the matching button.
128
+ * @example
129
+ * ```ts
130
+ * const saveButton = getButton(page, "Save");
131
+ * ```
132
+ */
133
+ function getButton(page, hasText) {
134
+ return getLocatorByText(page, ["button", hasText]);
135
+ }
136
+ //#endregion
137
+ //#region src/features/playwright/shared/locators/utils/getLabel.ts
138
+ /**
139
+ * Locates a label by its contained text.
140
+ *
141
+ * @param page The Playwright page to search.
142
+ * @param hasText Text or regular expression contained by the label.
143
+ * @returns A locator for the matching label.
144
+ * @example
145
+ * ```ts
146
+ * const emailLabel = getLabel(page, "Email");
147
+ * ```
148
+ */
149
+ function getLabel(page, hasText) {
150
+ return getLocatorByText(page, ["label", hasText]);
151
+ }
152
+ //#endregion
153
+ //#region src/features/playwright/shared/locators/utils/getLink.ts
154
+ /**
155
+ * Locates a link by its accessible name.
156
+ *
157
+ * @param page The Playwright page to search.
158
+ * @param hasText Text or regular expression matching the link's accessible name.
159
+ * @returns A locator for the matching link.
160
+ * @example
161
+ * ```ts
162
+ * const documentationLink = getLink(page, "Documentation");
163
+ * ```
164
+ */
165
+ function getLink(page, hasText) {
166
+ return page.getByRole("link", { name: hasText });
167
+ }
168
+ //#endregion
169
+ //#region src/features/playwright/modules/interactions/utils/clickButton.ts
170
+ /**
171
+ * Clicks a button matching the supplied text.
172
+ *
173
+ * @param page The Playwright page to search.
174
+ * @param hasText Text or regular expression contained by the button.
175
+ * @returns A promise that resolves after the button is clicked.
176
+ * @example
177
+ * ```ts
178
+ * await clickButton(page, "Save");
179
+ * ```
180
+ */
181
+ async function clickButton(page, hasText) {
182
+ await getButton(page, hasText).click();
183
+ }
184
+ //#endregion
185
+ //#region src/features/playwright/modules/interactions/utils/clickLabelInput.ts
186
+ /**
187
+ * Clicks the label matching the supplied text.
188
+ *
189
+ * @param page The Playwright page to search.
190
+ * @param labelText Text or regular expression contained by the label.
191
+ * @returns A promise that resolves after the label is clicked.
192
+ * @example
193
+ * ```ts
194
+ * await clickLabelInput(page, "Subscribe");
195
+ * ```
196
+ */
197
+ async function clickLabelInput(page, labelText) {
198
+ await getLabel(page, labelText).click();
199
+ }
200
+ //#endregion
201
+ //#region src/features/playwright/modules/interactions/utils/clickLink.ts
202
+ /**
203
+ * Clicks a link matching the supplied accessible name.
204
+ *
205
+ * @param page The Playwright page to search.
206
+ * @param hasText Text or regular expression matching the link name.
207
+ * @returns A promise that resolves after the link is clicked.
208
+ * @example
209
+ * ```ts
210
+ * await clickLink(page, "Documentation");
211
+ * ```
212
+ */
213
+ async function clickLink(page, hasText) {
214
+ await getLink(page, hasText).click();
215
+ }
216
+ //#endregion
217
+ //#region src/features/playwright/modules/interactions/utils/clickMultipleLabelInputs.ts
218
+ /**
219
+ * Clicks each matching label in the supplied order.
220
+ *
221
+ * @param page The Playwright page to search.
222
+ * @param labelTexts Text or regular expressions for the labels to click.
223
+ * @returns A promise that resolves after all labels are clicked.
224
+ * @example
225
+ * ```ts
226
+ * await clickMultipleLabelInputs(page, ["Email", "Subscribe"]);
227
+ * ```
228
+ */
229
+ async function clickMultipleLabelInputs(page, labelTexts) {
230
+ for (const labelText of labelTexts) await clickLabelInput(page, labelText);
231
+ }
232
+ //#endregion
233
+ //#region src/features/playwright/modules/interactions/utils/fillLocatorWith.ts
234
+ /**
235
+ * Clicks a locator and fills it with the supplied value.
236
+ *
237
+ * @param locator The input-like locator to fill.
238
+ * @param value The value to enter.
239
+ * @returns A promise that resolves after the locator is filled.
240
+ * @example
241
+ * ```ts
242
+ * await fillLocatorWith(page.getByLabel("Email"), "user@example.com");
243
+ * ```
244
+ */
245
+ async function fillLocatorWith(locator, value) {
246
+ await locator.click();
247
+ await locator.fill(value);
248
+ }
249
+ //#endregion
250
+ //#region src/features/playwright/modules/interactions/utils/setLocatorValue.ts
251
+ /**
252
+ * Clicks the label matching the pattern and fills it with the supplied value.
253
+ *
254
+ * @param page The Playwright page to search.
255
+ * @param locatorAndValue Label text or pattern paired with the value to fill.
256
+ * @returns A promise that resolves after the matching label is filled.
257
+ * @example
258
+ * ```ts
259
+ * await setLocatorValue(page, ["Email", "user@example.com"]);
260
+ * ```
261
+ */
262
+ async function setLocatorValue(page, [locator, value]) {
263
+ const element = page.locator("label", { hasText: require_pattern_to_regex.patternToRegex(locator) });
264
+ await element.click();
265
+ await element.fill(value);
266
+ }
267
+ //#endregion
268
+ //#region src/features/playwright/modules/interactions/utils/setValueForLocators.ts
269
+ /**
270
+ * Sets values for a sequence of label/value pairs in order.
271
+ *
272
+ * @param page The Playwright page to search.
273
+ * @param locatorsAndValues Label text or pattern paired with its value.
274
+ * @returns A promise that resolves after all values are set.
275
+ * @example
276
+ * ```ts
277
+ * await setValueForLocators(page, [
278
+ * ["Email", "user@example.com"],
279
+ * ["Name", "Alex"],
280
+ * ]);
281
+ * ```
282
+ */
283
+ async function setValueForLocators(page, locatorsAndValues) {
284
+ for (const locatorAndValue of locatorsAndValues) await setLocatorValue(page, locatorAndValue);
285
+ }
286
+ //#endregion
287
+ //#region src/features/playwright/modules/runners/utils/runSimilarTests.ts
288
+ /**
289
+ * Registers tests that share the same page navigation and setup.
290
+ *
291
+ * @param tests Tuples of test names followed by page callbacks.
292
+ * @returns Nothing; registers one Playwright test for each tuple.
293
+ * @example
294
+ * ```ts
295
+ * runSimilarTests([
296
+ * ["shows the home page", async (page) => {
297
+ * await page.getByRole("heading", { name: "Home" }).waitFor();
298
+ * }],
299
+ * ]);
300
+ * ```
301
+ */
302
+ function runSimilarTests(...tests) {
303
+ tests.forEach(([testName, ...testFunctions]) => (0, _playwright_test.default)(testName, async ({ page }) => {
304
+ await page.goto("/");
305
+ for (const testFunction of testFunctions) await testFunction(page);
306
+ }));
307
+ }
308
+ //#endregion
309
+ exports.clickBodyCorner = clickBodyCorner;
310
+ exports.clickButton = clickButton;
311
+ exports.clickLabelInput = clickLabelInput;
312
+ exports.clickLink = clickLink;
313
+ exports.clickMultipleLabelInputs = clickMultipleLabelInputs;
314
+ exports.fillLocatorWith = fillLocatorWith;
315
+ exports.getButton = getButton;
316
+ exports.getLabel = getLabel;
317
+ exports.getLink = getLink;
318
+ exports.getLocatorByText = getLocatorByText;
319
+ exports.isChecked = isChecked;
320
+ exports.isNotChecked = isNotChecked;
321
+ exports.runSimilarTests = runSimilarTests;
322
+ exports.setLocatorValue = setLocatorValue;
323
+ exports.setValueForLocators = setValueForLocators;
324
+ exports.shouldNotSee = shouldNotSee;
325
+ exports.shouldSee = shouldSee;
326
+
327
+ //# sourceMappingURL=playwright.cjs.map