/** * @file * * Vitest global setup and teardown adapter. * * Delegates to the framework-agnostic core and bridges context * to test workers via Vitest's `project.provide` / `inject`. */ import type { TestProject } from 'vitest/node'; import type { PopulateFilesParams } from '../temporary-vault.mjs'; import { TemporaryVault } from '../temporary-vault.mjs'; /** * Options for {@link createSetup}. */ export interface CreateSetupOptions { /** * Community-plugin ids to enable in the vault in addition to the plugin-under-test, * after it is enabled (see {@link CoreSetupOptions.enableCommunityPlugins}). Seed each * plugin's built files via {@link CreateSetupOptions.populate} (e.g. with `buildDemoVaultPopulate`) * so the enable finds them on disk. */ readonly enableCommunityPlugins?: readonly string[]; /** * Whether to install and enable the built plugin in the temp vault. Defaults * to `true`. Set to `false` for a **non-plugin** consumer that only needs a * registered, empty vault to `evalInObsidian` against — the owned instance is * still launched and its endpoint published to workers, so re-exporting * `createSetup({ installPlugin: false })` reuses the same attach wiring with no * plugin copy/enable. See {@link CoreSetupOptions.installPlugin}. */ readonly installPlugin?: boolean; /** * Returns files/folders to write into the vault before Obsidian opens it (see * {@link CoreSetupOptions.populate}). A thunk so large fixtures are built lazily, * once, in the setup process. * * May return a promise, so the map can be built by something that needs the network — notably * `buildDemoVaultPopulateAsync`, which installs a demo vault's missing community plugins before * reading them. A synchronous thunk (e.g. `buildDemoVaultPopulate`) is unchanged. */ readonly populate?: (this: void) => PopulateFilesParams | Promise; } /** * A Vitest `globalSetup` module's `setup` / `teardown` pair. */ export interface VitestGlobalSetup { setup: (this: void, project: TestProject) => Promise; teardown: (this: void) => Promise; } /** * Creates a Vitest global setup/teardown pair, optionally pre-populating the vault * before Obsidian opens it — use this for a dedicated large-vault/performance * project. The plain {@link setup} / {@link teardown} exports are the no-populate * case (`createSetup()`). Pass `{ installPlugin: false }` for a non-plugin consumer * that only needs a registered, empty vault (see {@link CreateSetupOptions.installPlugin}). * * @param options - Setup options. * @returns The `setup` and `teardown` functions to re-export from a `globalSetup` module. */ export declare function createSetup(options?: CreateSetupOptions): VitestGlobalSetup; /** * Returns the temporary vault provided by the global setup. * * @returns The temporary vault. */ export declare function getTemporaryVault(): TemporaryVault; /** * Vitest global setup function (no pre-population). * * Copies the built plugin into a temporary vault, enables it via a renderer eval * over the transport, and provides `temporaryVaultPath` to tests. * * @param project - The Vitest project. * @returns A promise that resolves when setup completes. */ export declare const setup: (this: void, project: TestProject) => Promise; /** * Vitest global teardown function. * * Removes the temporary vault created during setup. * * @returns A promise that resolves when teardown completes. */ export declare const teardown: (this: void) => Promise;