@vickbk/tests 0.1.0 → 0.2.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 CHANGED
@@ -1,21 +1,39 @@
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.
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.2.0] - 2026-10-27
11
+
12
+ ### Added
13
+
14
+ - Add `@vickbk/tests/vitest/console` as a dedicated entrypoint for console controls.
15
+ - Add `@vickbk/tests/vitest/dom` as a dedicated entrypoint for DOM queries, assertions, interactions, and toggle-event support.
16
+ - Add `@vickbk/tests/promises` as a framework-independent entrypoint for `resolvedPromise` and `rejectedPromise`.
17
+
18
+ ### Changed
19
+
20
+ - Organize Vitest helpers into specialized entrypoints so consumers can import only the helper categories they need.
21
+ - Update the root README and Vitest documentation to describe the public entrypoints, their intended use, and their dependency requirements.
22
+
23
+ ### Deprecated
24
+
25
+ - Deprecate `resolvedPromise` and `rejectedPromise` when imported from `@vickbk/tests/vitest`. Use `@vickbk/tests/promises` instead.
26
+ - Retain the deprecated promise exports from the aggregate Vitest entrypoint for backward compatibility.
27
+
28
+ ## [0.1.0] - 2026-10-24
29
+
30
+ ### Added
31
+
32
+ - Shared text-pattern utilities and types, including `patternToRegex`, `LABEL_LOCATOR`, `TEXT_MATCHER`, `TEXT_PATTERN`, and `TEXT_WITH_NTH` through `@vickbk/tests`.
33
+ - Vitest utilities for DOM assertions, console controls, user interactions, promise helpers, and toggle-event handling through `@vickbk/tests/vitest`.
34
+ - React Server Component tree resolution through `@vickbk/tests/react`.
35
+ - Playwright utilities for assertions, locators, interactions, and reusable test execution through `@vickbk/tests/playwright`.
36
+ - Public package entrypoints for shared helpers, Vitest utilities, React utilities, and Playwright utilities.
37
+ - TypeScript declaration files for the published entrypoints.
38
+ - ESM and CommonJS builds for supported entrypoints, with the `@vickbk/tests/vitest` entrypoint published as ESM-only.
39
+ - Package documentation covering installation, peer dependencies, setup, and API usage.
package/LICENSE CHANGED
@@ -1,21 +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.
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,192 +1,226 @@
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
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 helpers, promise helpers, Vitest utilities, React Server Component helpers, and a Playwright DSL. Import only the entrypoint that matches the functionality and integrations your project needs.
9
+
10
+ ## Overview
11
+
12
+ The package is organized around focused public entrypoints:
13
+
14
+ - **Shared utilities** provide text-pattern helpers and types.
15
+ - **Promise helpers** provide settled-promise utilities without requiring Vitest or Testing Library.
16
+ - **Vitest utilities** provide console controls, DOM assertions and interactions, and toggle-event support.
17
+ - **React utilities** provide React Server Component (RSC) tree resolution.
18
+ - **Playwright utilities** provide assertions, locators, interactions, and a reusable runner.
19
+
20
+ > The Vitest Aggregate entrypoint re-exports console, DOM, and promises (Deprecated) helpers. For dependency isolation, prefer the specialized entrypoint that matches your needs.
21
+
22
+ ## Installation
23
+
24
+ Install the package as a development dependency:
25
+
26
+ ```sh
27
+ pnpm add -D @vickbk/tests
28
+ ```
29
+
30
+ Install the peer dependencies required by the integrations you use.
31
+
32
+ For Vitest DOM tests:
33
+
34
+ ```sh
35
+ pnpm add -D vitest jsdom @testing-library/react @testing-library/user-event @testing-library/jest-dom
36
+ ```
37
+
38
+ For console helpers, install Vitest.
39
+
40
+ For promise helpers, no dependency is required by the promises entrypoint.
41
+
42
+ For Playwright tests, install `@playwright/test`.
43
+ For React Server Component helpers, install `react` and `react-dom` (and `@types/react` when using TypeScript).
44
+
45
+ ## Public entrypoints
46
+
47
+ | Import path | Purpose |
48
+ | ------------------------------ | -------------------------------------------------------------------------------- |
49
+ | `@vickbk/tests` | Shared text-pattern utilities and types |
50
+ | `@vickbk/tests/promises` | Framework-independent settled-promise helpers |
51
+ | `@vickbk/tests/vitest` | Aggregate Vitest API: console, DOM, toggle-event, and deprecated promise exports |
52
+ | `@vickbk/tests/vitest/console` | Console controls using Vitest spies |
53
+ | `@vickbk/tests/vitest/dom` | DOM queries, assertions, interactions, and toggle-event support |
54
+ | `@vickbk/tests/react` | React Server Component tree resolution |
55
+ | `@vickbk/tests/playwright` | Playwright assertions, locators, interactions, and runner |
56
+
57
+ **Module format:** The `@vickbk/tests/vitest`, `@vickbk/tests/vitest/console` and `@vickbk/tests/vitest/dom` entrypoints are ESM-only. Use `import` to consume them; CommonJS `require()` is not supported. Other entrypoints support dual module format.
58
+
59
+ ## Shared text-pattern helpers
60
+
61
+ The shared API provides `patternToRegex` and the `LABEL_LOCATOR`, `TEXT_MATCHER`, `TEXT_PATTERN`, and `TEXT_WITH_NTH` types.
62
+
63
+ ```ts
64
+ import { patternToRegex, type TEXT_MATCHER } from "@vickbk/tests";
65
+
66
+ const matcher: TEXT_MATCHER = ["Welcome", 0];
67
+ const caseInsensitive = patternToRegex("Welcome");
68
+ ```
69
+
70
+ ## Promise helpers
71
+
72
+ The dedicated promises entrypoint provides `resolvedPromise` and `rejectedPromise`. These helpers produce settled promises with Vitest-style `status` and `value`/`reason` properties, useful when testing consumers that inspect promise state.
73
+
74
+ ```ts
75
+ import { rejectedPromise, resolvedPromise } from "@vickbk/tests/promises";
76
+
77
+ const ready = resolvedPromise({ id: "item-1" });
78
+ expect(ready.status).toBe("fulfilled");
79
+ expect(ready.value.id).toBe("item-1");
80
+
81
+ await expect(rejectedPromise(new Error("unavailable"))).rejects.toThrow(
82
+ "unavailable",
83
+ );
84
+ ```
85
+
86
+ Prefer `@vickbk/tests/promises` for all new code. The same helpers remain exported from `@vickbk/tests/vitest` for backward compatibility, but those re-exports are deprecated. Migrate existing imports to the dedicated promises entrypoint.
87
+
88
+ ## Vitest setup
89
+
90
+ The package supports Node.js 20 and newer. Its peer dependency ranges are:
91
+
92
+ | Peer dependency | Supported range | Used for |
93
+ | ----------------------------- | ---------------------- | ----------------------------------------------------- |
94
+ | `vitest` | `^5.0.4` | Vitest helpers, including console controls |
95
+ | `@testing-library/react` | `^16.0.0` | DOM queries, interactions, and toggle events |
96
+ | `@testing-library/user-event` | `^14.6.8` | User-like DOM interactions |
97
+ | `@testing-library/jest-dom` | `^7.0.1` | DOM matcher setup used by assertion helpers |
98
+ | `@playwright/test` | `^1.64.0` | Playwright helpers and direct `test`/`expect` exports |
99
+ | `react`, `react-dom` | `^18.0.0` or `^19.0.0` | React integrations and RSC helpers |
100
+ | `@types/react` | `^18.0.0` or `^19.0.0` | React TypeScript types |
101
+
102
+ All peers are optional at the package level. Install the peers required by the entrypoints your project imports.
103
+ In particular, the promises entrypoint does not require any Library, and the console entrypoint requires vitest only.
104
+
105
+ Configure Vitest to use a DOM environment for tests that render components, and load the jest-dom Vitest matchers from a setup file:
106
+
107
+ ```ts
108
+ // vitest.config.ts
109
+ import { defineConfig } from "vitest/config";
110
+
111
+ export default defineConfig({
112
+ test: {
113
+ environment: "jsdom",
114
+ setupFiles: ["./tests/setup.ts"],
115
+ },
116
+ });
117
+ ```
118
+
119
+ ```ts
120
+ // tests/setup.ts
121
+ import "@testing-library/jest-dom/vitest";
122
+ ```
123
+
124
+ ## Vitest utilities
125
+
126
+ The aggregate entrypoint, `@vickbk/tests/vitest`, re-exports the Vitest helper categories. For smaller dependency footprints, import from `@vickbk/tests/vitest/console` or `@vickbk/tests/vitest/dom` instead.
127
+
128
+ ### Console controls
129
+
130
+ The console entrypoint exports `shutConsole` and `resetConsole`. These helpers suppress `console.log`, `console.warn`, and `console.error` during tests, then restore the original implementations.
131
+
132
+ ```ts
133
+ import { afterEach, beforeEach } from "vitest";
134
+ import { resetConsole, shutConsole } from "@vickbk/tests/vitest/console";
135
+
136
+ beforeEach(shutConsole);
137
+ afterEach(resetConsole);
138
+ ```
139
+
140
+ Console output is not suppressed merely by importing the module. Call `shutConsole()` to activate the spies and `resetConsole()` to restore the methods.
141
+
142
+ ### DOM assertions and interactions
143
+
144
+ Import DOM helpers from the dedicated DOM entrypoint:
145
+
146
+ ```tsx
147
+ import { render } from "@testing-library/react";
148
+ import { shouldHaveTestId, shouldSee } from "@vickbk/tests/vitest/dom";
149
+
150
+ render(
151
+ <main>
152
+ <h1>Welcome</h1>
153
+ <button data-testid="save-button">Save</button>
154
+ </main>,
155
+ );
156
+
157
+ const [heading] = shouldSee("Welcome");
158
+ const [saveButton] = shouldHaveTestId("save-button");
159
+ ```
160
+
161
+ `shouldSee` returns the matched elements, while `shouldHaveTestId` returns the elements located by test ID.
162
+
163
+ Other DOM helpers include `shouldNotSee`, `isChecked`, `isNotChecked`, `shouldHaveAttributes`, `shouldNotHaveTestId`, `userClicks`, `userTypes`, `userTypesMultiple`, and `togglePopover`.
164
+
165
+ ### Toggle events
166
+
167
+ The DOM entrypoint provides its own `fireEvent`, combining standard Testing Library event helpers with the package's `toggle` helper. No separate toggle-event installation is needed.
168
+
169
+ ```ts
170
+ import { fireEvent } from "@vickbk/tests/vitest/dom";
171
+
172
+ fireEvent.click(document.body);
173
+ fireEvent.toggle(document.body);
174
+ fireEvent.toggle(document.body, {
175
+ oldState: "open",
176
+ newState: "closed",
177
+ });
178
+ ```
179
+
180
+ `fireEvent.toggle(element, config?)` defaults to `oldState: "closed"` and `newState: "open"`. Either state can be overridden independently. The package-owned `fireEvent` does not augment or modify Testing Library's original export.
181
+
182
+ ### Aggregate entrypoint and compatibility
183
+
184
+ The `@vickbk/tests/vitest` entrypoint continues to export the console and DOM helpers, along with `resolvedPromise` and `rejectedPromise`.
185
+
186
+ The promise re-exports are deprecated. Import these helpers from `@vickbk/tests/promises` in new code and when migrating existing imports.
187
+
188
+ The aggregate entrypoint is convenient when a project uses all the Vitest helper categories. It is not intended to provide the same dependency isolation as the specialized entrypoints.
189
+
190
+ [For more details on the Vitest API](./src/features/vitest/README.md)
191
+
192
+ ## React utilities
193
+
194
+ The React entrypoint exposes `resolveRscTree` for resolving React Server Component trees.
195
+
196
+ ```tsx
197
+ import { resolveRscTree } from "@vickbk/tests/react";
198
+
199
+ const resolved = await resolveRscTree(<ServerPage />);
200
+ ```
201
+
202
+ [For more on the React API](./src/features/react/README.md)
203
+
204
+ ## Playwright utilities
205
+
206
+ Playwright helpers are imported from `@vickbk/tests/playwright`.
207
+
208
+ ```ts
209
+ import { expect, test } from "@playwright/test";
210
+ import { clickButton, getButton, shouldSee } from "@vickbk/tests/playwright";
211
+
212
+ test("saves the page", async ({ page }) => {
213
+ await page.goto("/");
214
+ await shouldSee(page, "Welcome");
215
+ await clickButton(page, "Save");
216
+ await expect(getButton(page, "Save")).toBeVisible();
217
+ });
218
+ ```
219
+
220
+ The public API also includes `shouldNotSee`, `isChecked`, `isNotChecked`, `getLocatorByText`, `getLabel`, `getLink`, `fillLocatorWith`, `setLocatorValue`, `setValueForLocators`, `clickLink`, `clickLabelInput`, `clickMultipleLabelInputs`, `clickBodyCorner`, and `runSimilarTests`.
221
+
222
+ [For more details on the Playwright API](./src/features/playwright/README.md)
223
+
224
+ ## License
225
+
226
+ MIT
@@ -0,0 +1,39 @@
1
+ import { vi } from "vitest";
2
+ //#region src/features/vitest/modules/console/utils/console.ts
3
+ const CONSOLES = [
4
+ "log",
5
+ "warn",
6
+ "error"
7
+ ];
8
+ let activeSpies = [];
9
+ /**
10
+ * Suppresses console.log, console.warn, and console.error until resetConsole runs.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * beforeEach(shutConsole);
15
+ * afterEach(resetConsole);
16
+ * ```
17
+ */
18
+ function shutConsole() {
19
+ resetConsole();
20
+ activeSpies = CONSOLES.map((cons) => vi.spyOn(console, cons).mockImplementation(() => {}));
21
+ }
22
+ /**
23
+ * Restores the console methods most recently suppressed by shutConsole.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * shutConsole();
28
+ * // Run code whose console output should be ignored.
29
+ * resetConsole();
30
+ * ```
31
+ */
32
+ function resetConsole() {
33
+ for (const spy of activeSpies) spy.mockRestore();
34
+ activeSpies = [];
35
+ }
36
+ //#endregion
37
+ export { shutConsole as n, resetConsole as t };
38
+
39
+ //# sourceMappingURL=console-Cf1taTRK.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-Cf1taTRK.mjs","names":[],"sources":["../src/features/vitest/modules/console/utils/console.ts"],"sourcesContent":["import { MockInstance, vi } from \"vitest\";\n\nconst CONSOLES = [\"log\", \"warn\", \"error\"] as const;\n\nlet activeSpies: MockInstance[] = [];\n\n/**\n * Suppresses console.log, console.warn, and console.error until resetConsole runs.\n *\n * @example\n * ```ts\n * beforeEach(shutConsole);\n * afterEach(resetConsole);\n * ```\n */\nexport function shutConsole() {\n resetConsole();\n\n activeSpies = CONSOLES.map((cons) =>\n vi.spyOn(console, cons).mockImplementation(() => {}),\n );\n}\n\n/**\n * Restores the console methods most recently suppressed by shutConsole.\n *\n * @example\n * ```ts\n * shutConsole();\n * // Run code whose console output should be ignored.\n * resetConsole();\n * ```\n */\nexport function resetConsole() {\n for (const spy of activeSpies) {\n spy.mockRestore(); // Restores native console behavior\n }\n activeSpies = [];\n}\n"],"mappings":";;AAEA,MAAM,WAAW;CAAC;CAAO;CAAQ;AAAO;AAExC,IAAI,cAA8B,CAAC;;;;;;;;;;AAWnC,SAAgB,cAAc;CAC5B,aAAa;CAEb,cAAc,SAAS,KAAK,SAC1B,GAAG,MAAM,SAAS,IAAI,CAAC,CAAC,yBAAyB,CAAC,CAAC,CACrD;AACF;;;;;;;;;;;AAYA,SAAgB,eAAe;CAC7B,KAAK,MAAM,OAAO,aAChB,IAAI,YAAY;CAElB,cAAc,CAAC;AACjB"}