Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

browserSetup.ts

26 lines1.1 KB

1import { beforeEach } from "vite-plus/test";
2import { commands } from "vite-plus/test/browser";
3​
4import { initializeI18n } from "../src/i18n/initializeI18n";
5​
6declare module "vite-plus/test/browser" {
7 interface BrowserCommands {
8 /** Defined in vite.config.ts. Moves Playwright's mouse off the page. */
9 resetPointer: () => Promise<void>;
10 /** Defined in vite.config.ts. Presses the primary button where the mouse is, without releasing. */
11 pointerDown: () => Promise<void>;
12 /** Defined in vite.config.ts. Releases the primary button. */
13 pointerUp: () => Promise<void>;
14 }
16​
17// Playwright's mouse outlives each test and each file, so whatever the next test mounts
18// under its last position starts hovered. Registered here rather than in render() so tests
19// that mount without it are covered too. Before each test, not after: a timed-out test keeps
20// running and can move the mouse after its own afterEach.
21beforeEach(async () => {
22 await commands.resetPointer();
23});
24​
25// The app initializes GT at startup; components using its hooks need the same here.
26initializeI18n(() => {});