Skip to content

script-utils/test-runners/vitest-config

Shared vitest configuration for Obsidian plugins.

Every plugin in the workspace declares the same five vitest projects — unit-tests plus the integration-tests:{no-app,desktop,desktop-performance,android} family — with the same timeouts, setupFiles, and globalSetup wiring. Maintaining that per repo means a convention change costs one near-identical edit per plugin, and any repo that is missed drifts silently. This module owns that configuration once, so a plugin’s scripts/vitest-config.ts collapses to a single call.

The seam mirrors the ESLint one (defineEslintConfigs): the factory builds a context holding the standard projects, the caller edits it in place through DefineObsidianPluginVitestConfigOptions.editContext, and appends any project the base does not know about through DefineObsidianPluginVitestConfigOptions.customProjects.

ClassDescription
ObsidianPluginVitestConfigContextThe context for defining a plugin’s vitest configuration. Every member is live: the arrays and objects it exposes are the very ones the assembled configuration is built from, so editing them in place through DefineObsidianPluginVitestConfigOptions.editContext is what customizes the result.
InterfaceDescription
DefineObsidianPluginVitestConfigOptionsThe options for defining a plugin’s vitest configuration.
FunctionDescription
defineObsidianPluginVitestConfigDefines the vitest configuration for an Obsidian plugin.
TypeDescription
ObsidianPluginVitestProjectConfigThe test section of a single vitest project entry.