vitest-plugin-vis
Version:
Vitest visual testing plugin
106 lines (105 loc) • 3.39 kB
text/typescript
import { n as ComparisonMethod, p as SetupVisOptions, w as SnapshotMeta } from "./types-CEmjj-A9.mjs";
import "./types-DJYCbyT8.mjs";
import { s as SetupVisSuiteCommand } from "./commands.types-BVhcnnHw.mjs";
import "./to_match_image_snapshot.types--tTmHoRA.mjs";
import "./augment-C1tjdh5B.mjs";
//#region src/setup/create_vis.d.ts
/**
* Visual test configuration on the client side.
*/
type VisClientConfigurator<GM extends Record<string, any> | unknown = unknown> = {
/**
* Setup the visual test configuration.
*
* @example
* ```ts
* // Setup with auto snapshot enabled
* vis().setup({ auto: true })
*
* // Setup with auto snapshot disabled
* vis().setup({ auto: false })
*
* // Same as `vis.setup({ auto: false })`
* vis.setup()
*
* // Setup with auto snapshot determined by the test meta
* vis.setup({
* auto: async ({ meta }) => meta['darkOnly'],
* })
*
* // Setup with multiple auto snapshots
* vis.setup({
* auto: {
* async light() { document.body.classList.remove('dark') },
* async dark() { document.body.classList.add('dark') },
* }
* })
* ```
*/
setup(options?: SetupVisOptions<GM>): void;
/**
* @deprecated Use `vis.setup()` instead.
*/
presets: {
/**
* @deprecated Use `vis.setup()` instead.
*
* Enable visual testing.
*
* auto snapshot is turned off by default.
* You can specify the test to take a snapshot during `afterEach()` hook with `setAutoSnapshotOptions()`.
*/
enable(): void;
/**
* @deprecated Use `vis.setup()` instead.
*
* Enable visual testing.
*
* `setAutoSnapshotOptions` will have no effect in this preset.
*/
manual(): void;
/**
* @deprecated Use `vis.setup()` instead.
*
* Enable automatic visual testing.
*
* This will take a snapshot after each test.
*/
auto(): void;
/**
* @deprecated Use `vis.setup()` instead.
*
* Enable automatic visual testing with multiple themes.
*
* This will take a snapshot after each test for each theme.
*
* @param themes A record of theme names and their setup functions.
*
* @example
* ```ts
* vis().presets.theme({
* light() { document.body.classList.add('light') },
* dark() { document.body.classList.add('dark') },
* })
* ```
*/
theme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): void;
};
beforeAll: {
setup(): Promise<void>;
};
afterEach: {
matchImageSnapshot(): Promise<void>;
matchPerTheme<C extends ComparisonMethod, M extends Record<string, any> | unknown = unknown>(themes: Record<string, boolean | ((options: SnapshotMeta<C> & M & GM) => Promise<boolean> | Promise<void> | boolean | void)>): () => Promise<void>;
};
};
declare function createVis<GM extends Record<string, any> | unknown = unknown>(commands: SetupVisSuiteCommand): VisClientConfigurator<GM>;
//#endregion
//#region src/setup/vis.d.ts
/**
* Visual test configuration on the client side.
*/
declare const vis: VisClientConfigurator<unknown>;
//#endregion
export { VisClientConfigurator, createVis, vis };
//# sourceMappingURL=setup.d.mts.map