UNPKG

histoire

Version:

A fast story book powered by Vite

52 lines • 2.71 kB
import type { InlineConfig, Plugin as VitePlugin } from 'vite'; import type { Vitest } from 'vitest/node'; /** * Builds the default `test` options of a browser run: headless chromium through * the project's own `@vitest/browser-playwright`, with Histoire's plugins. * @param root Project root, used to resolve the provider package. * @param plugins Vite plugins the browser server must also apply. * @param optimizeDeps Reachable dependency policy, applied to the browser server only. * @param serverConfig Other Vite options of the browser server (see {@link getVitestBrowserServerConfig}). */ export declare function getVitestBrowserProjectConfig(root: string, plugins?: VitePlugin[], optimizeDeps?: InlineConfig['optimizeDeps'], serverConfig?: InlineConfig): Promise<{ browser: { enabled: boolean; ui: boolean; headless: boolean; provider: any; instances: { browser: 'chromium'; }[]; }; plugins: VitePlugin<any>[]; }>; /** * Vite options the browser server needs from a run's Vite config. * * Vitest creates that server from `project.options` and the project's config * file only, never from the inline config of `createVitest`. Histoire's * configs are inline (`configFile: false`), so without this copy framework * and user options (Nuxt's `#app` aliases, `resolve.dedupe`, `css`, * `publicDir`, `server.fs.allow`, …) never reach the page. Vitest overwrites * the keys it owns (`root`, `base`, `define`, `cacheDir`, `mode`, …). * * Left out: `plugins` (passed separately) and `test` (Vitest options). * `optimizeDeps` comes from the framework and user config, not from the run's * own lists: their `include` pre-bundles CommonJS dependencies the page would * fail to import raw. Its `entries` and `noDiscovery` are left out: Histoire's * core plugin disables discovery by default, and variant tests apply their * optimizer policy on the browser server separately. * @param viteConfig The run's Vite config. * @param optimizeDeps The framework and user optimizer config. */ export declare function getVitestBrowserServerConfig(viteConfig: InlineConfig, optimizeDeps?: InlineConfig['optimizeDeps']): InlineConfig; /** Launch owned Chromium alongside optimization, without opening a context or tester document. */ export declare function prepareVitestCollectionProvider(provider: unknown): Promise<void>; /** * Pushes Histoire's Vite plugins onto every project of an already-created * Vitest instance (see the COMPAT note above). */ export declare function assignVitestBrowserProjectOptions(vitest: Vitest, options: { plugins: VitePlugin[]; }): void; //# sourceMappingURL=browser-project.d.ts.map