Skip to content
Source
Sign inSign up

browserSetup.ts

22 lines862 Bytes

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 }
12​
13// Playwright's mouse outlives each test and each file, so whatever the next test mounts
14// under its last position starts hovered. Registered here rather than in render() so tests
15// that mount without it are covered too. Before each test, not after: a timed-out test keeps
16// running and can move the mouse after its own afterEach.
17beforeEach(async () => {
18 await commands.resetPointer();
19});
20​
21// The app initializes GT at startup; components using its hooks need the same here.
22initializeI18n(() => {});