Skip to content

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.

Class Description
ObsidianPluginVitestConfigContext The 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.
Interface Description
DefineObsidianPluginVitestConfigOptions The options for defining a plugin’s vitest configuration.
Function Description
defineObsidianPluginVitestConfig Defines the vitest configuration for an Obsidian plugin.
Type Description
ObsidianPluginVitestProjectConfig The test section of a single vitest project entry.
ObsidianPluginVitestReporter One entry of a vitest reporters list: the name of a built-in reporter or a reporter instance. The same shape as the library configuration’s VitestReporter.
Variable Description
INTEGRATION_TEST_TIMEOUT_IN_MILLISECONDS The per-test budget of the regular integration projects, in milliseconds. Exported because a repo that assembles its vitest projects by hand instead of through defineObsidianPluginVitestConfig still needs the same relationship to the per-eval cap, and restating the number there is how the two drift apart.