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

browserSetup.ts

17 lines688 Bytes

1import { beforeEach } from "vite-plus/test";
2import { commands } from "vite-plus/test/browser";
3​
4declare 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.
15beforeEach(async () => {
16 await commands.resetPointer();
17});