import type { ResolvedConfig } from 'vitest' export type BufferEncoding = | 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'utf-16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex' export interface FsOptions { encoding?: BufferEncoding flag?: string | number } export interface TypePayload { type: string } export interface PressPayload { press: string } export interface DownPayload { down: string } export interface UpPayload { up: string } export type SendKeysPayload = TypePayload | PressPayload | DownPayload | UpPayload export interface BrowserCommands { readFile: (path: string, options?: BufferEncoding | FsOptions) => Promise writeFile: (path: string, content: string, options?: BufferEncoding | FsOptions & { mode?: number | string }) => Promise removeFile: (path: string) => Promise sendKeys: (payload: SendKeysPayload) => Promise } export interface UserEvent { /** * Click on an element. Uses provider's API under the hood and supports all its options. * @see {@link https://playwright.dev/docs/api/class-locator#locator-click} Playwright API * @see {@link https://webdriver.io/docs/api/element/click/} WebdriverIO API * @see {@link https://testing-library.com/docs/user-event/convenience/#click} testing-library API */ click: (element: Element, options?: UserEventClickOptions) => Promise } export interface UserEventClickOptions { [key: string]: any } type Platform = | 'aix' | 'android' | 'darwin' | 'freebsd' | 'haiku' | 'linux' | 'openbsd' | 'sunos' | 'win32' | 'cygwin' | 'netbsd' export const server: { /** * Platform the Vitest server is running on. * The same as calling `process.platform` on the server. */ platform: Platform /** * Runtime version of the Vitest server. * The same as calling `process.version` on the server. */ version: string /** * Name of the browser provider. */ provider: string /** * Name of the current browser. */ browser: string /** * Available commands for the browser. * @see {@link https://vitest.dev/guide/browser#commands} */ commands: BrowserCommands } /** * Handler for user interactions. The support is provided by the browser provider (`playwright` or `webdriverio`). * If used with `none` provider, fallbacks to simulated events via `@testing-library/user-event`. * @experimental */ export const userEvent: UserEvent /** * Available commands for the browser. * A shortcut to `server.commands`. * @see {@link https://vitest.dev/guide/browser#commands} */ export const commands: BrowserCommands export const page: { /** * Serialized test config. */ config: ResolvedConfig /** * Change the size of iframe's viewport. */ viewport: (width: number, height: number) => Promise }