@lewiswright/vitest-plugin-vis
Version:
Vitest visual testing plugin
29 lines (28 loc) • 930 B
JavaScript
import { commands } from "../server/commands/extend.js";
import { visContext } from "../server/vis_context.js";
import { NAME } from "../shared/constants.js";
/**
* Create a Vite plugin for visual testing.
*
* If options are not provided, the plugin will use the default options,
* which enables the `auto` preset.
*/
export function vis(options = { preset: 'auto' }) {
return {
name: NAME,
config(userConfig) {
const projectName = userConfig?.test?.name;
visContext.setOptions(projectName, options);
const preset = options?.preset;
return {
test: {
browser: {
name: undefined,
commands,
},
setupFiles: preset && preset !== 'none' ? [`vitest-plugin-vis/presets/${preset}`] : [],
},
};
},
};
}