@devries-cameron20 / t3code-1 / commits / c728c8ce19
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

test(web): every browser test starts with the mouse off the page (#22556)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 20, 2026 at 18:42 UTC c728c8ce19b0797baa2e8a1356735cc3aff979bb
3 files changed +20 -13
apps/web/test/browserSetup.ts new
+17
@@ -0,0 +1,17 @@
1 +import { beforeEach } from "vite-plus/test";
2 +import { commands } from "vite-plus/test/browser";
3 +
4 +declare module "vite-plus/test/browser" {
5 + interface BrowserCommands {
6 + /** Defined in vite.config.ts. Moves Playwright's mouse off the page. */
7 + resetPointer: () => Promise<void>;
8 + }
9 +}
10 +
11 +// Playwright's mouse outlives each test and each file, so whatever the next test mounts
12 +// under its last position starts hovered. Registered here rather than in render() so tests
13 +// that mount without it are covered too. Before each test, not after: a timed-out test keeps
14 +// running and can move the mouse after its own afterEach.
15 +beforeEach(async () => {
16 + await commands.resetPointer();
17 +});
apps/web/test/render.tsx
+1 -12
@@ -8,19 +8,12 @@ import {
8 import { act as reactAct, createContext, use, type ReactNode } from "react";
9 import { createRoot } from "react-dom/client";
10 import { vi } from "vite-plus/test";
11 -import { commands, page, utils, type Locator, type LocatorSelectors } from "vite-plus/test/browser";
11 +import { page, utils, type Locator, type LocatorSelectors } from "vite-plus/test/browser";
12
13 declare global {
14 var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
15 }
16
17 -declare module "vite-plus/test/browser" {
18 - interface BrowserCommands {
19 - /** Defined in vite.config.ts. Moves Playwright's mouse off the page. */
20 - resetPointer: () => Promise<void>;
21 - }
22 -}
23 -
17 // React warns about every update outside act() while this flag is on, and a real
18 // browser drives updates from userEvent, timers and network that act() cannot wrap.
19 // So it is on only while act() runs, and nested calls restore the outer value.
@@ -104,10 +97,6 @@ export async function render(
97 await unmount();
98 } finally {
99 container.remove();
107 - // The real mouse outlives the test, and whatever the next test mounts under it
108 - // starts hovered. Parking it here keeps render() itself free of awaits before
109 - // the first mount, which tests rely on.
110 - await commands.resetPointer();
100 }
101 },
102 };
apps/web/vite.config.ts
+2 -1
@@ -102,6 +102,7 @@ const browserTestProject = {
102 include: ["src/**/*.browser.test.{ts,tsx}"],
103 hookTimeout: 15_000,
104 testTimeout: 15_000,
105 + setupFiles: ["./test/browserSetup.ts"],
106 api: { port: browserTestApiPort, strictPort: false },
107 browser: {
108 enabled: true,
@@ -111,7 +112,7 @@ const browserTestProject = {
112 screenshotFailures: false,
113 commands: {
114 // Playwright's mouse outlives each test, so whatever mounts under its last
114 - // position starts hovered. test/render.tsx parks it off the page after each test.
115 + // position starts hovered. test/browserSetup.ts parks it off the page before each test.
116 resetPointer: async ({ page }) => {
117 await page.mouse.move(-1, -1);
118 },