import { TestProject } from 'vitest/node'; import { ConnectOptions } from 'puppeteer'; declare module "vitest" { interface ProvidedContext { isDevToolsEnabled?: boolean; isHeadlessBrowser?: boolean; devServerHtml?: string; devServerUrl?: string; puppeteerConnectOptions?: ConnectOptions; puppeteerWaitForChangesDelay?: number; } } /** * Global setup file for Vitest Puppeteer integration. * * This is run once, in the main thread, before any tests are run. * * We start browser via Puppeteer so that tests can render to it and interact * with it. * * In the browser, we render the test suite. The browser sends requests for * JavaScript files to the Vite dev server. * * We start that Vite dev server in this file too. It is separate from the * Vite dev server started by Vitest. * * It has to be separate because Vitest's dev server resolves imports for the * "node" import condition. If we instead tell Vitest to use browser export * conditions, then Lit's "isServer" will be false both in browser and node.js, * potentially breaking some components. While happy-dom is neat, it does match * the actual browser API 100%. It is safer to run a separate Vite instance for * Node.js (Vitest) and browser. This is a short-term issue anyway as we are * looking to moving to Vitest browser mode feature, that would resolve this * issue. * * Here is an example Vite configuration plugin that is needed if you wish to * make Vitest's Vite instance somewhat usable directly by Playwright's browser: * ```ts * config: (config) => { * const conditions = config.resolve?.conditions; * // Remove "node" condition. * // Can't do this imperatively as Vite's default configuration merging only * // allows adding settings, not removing. * if (conditions && conditions.includes("node")) { * conditions.splice(conditions.indexOf("node"), 1); * } * return { * server: { * middlewareMode: false, * }, * test: { * api: true, * environment: "happy-dom", * }, * }; * }, * * Vite's upcoming Environment API will make it possible to use a single dev * server (https://github.com/vitejs/vite/pull/16089/files). However, we plan * to provide Puppeteer integration only temporary to ease the Stencil * migration, so optimizing it too much is not a goal. */ export declare function setup(context: TestProject): Promise<() => Promise>; export type PuppeteerViteGlobals = { /** * Helps lumina-compiler dev server know that is it running for Puppeteer * browser. * * Not exposing this in global typings for usage in tests because * `import.meta.env.MODE` should be used instead. */ __IS_IN_PUPPETEER__?: true; };