Skip to content

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.

Import:

import { ObsidianPluginVitestConfigContext } from '@mnaoumov/obsidian-dev-toolkit/test-runners/vitest-config';

Signature:

export class ObsidianPluginVitestConfigContext

Constructor

new ObsidianPluginVitestConfigContext()

Creates a new context seeded with the standard projects.

Properties

PropertyTypeDescription
androidObsidianPluginVitestProjectConfigThe integration-tests:android project, running the mobile-only and cross-platform suites against an Android emulator through Appium.
androidTimeoutInMilliseconds60000The per-test budget of the Android integration project, in milliseconds. Booting an emulator and driving it over Appium is slower than the desktop path, hence its own constant.
bigTimeoutInMillisecondsnumberThe per-test budget of the regular integration projects, in milliseconds.

It deliberately CLEARS the transports' per-eval cap rather than matching it, so that a closure which outruns the cap fails with the harness's EvalCapExceededError — naming the cap and the remedy — instead of with vitest's anonymous timeout. Lowering it to the cap restores that blind spot.
coverageExcludestring[]The coverage exclude globs. Push onto it to drop more files from the coverage report.

Declaration files are excluded by default because the coverage include below is src/**\/*.ts, which a .d.ts matches. A declaration file emits no runtime code, so it reports 0% and no test can ever raise it — a plugin that grows one under src/ silently loses its 100% gate, and the usual remedy of an inline v8 ignore comment does not apply to a type-only file.
desktopObsidianPluginVitestProjectConfigThe integration-tests:desktop project, running the desktop-only and cross-platform suites against a real desktop Obsidian over CDP.
desktopPerformanceObsidianPluginVitestProjectConfigThe integration-tests:desktop-performance project, running the at-scale suites. It is declared for every plugin even when there is no such suite yet — passWithNoTests makes an empty project free, and the matching test:integration:desktop:performance script exists in every plugin built on this library.

A plugin's test:integration aggregate leaves this project out on purpose, and it stays out even on a machine with a desktop Obsidian set up. The reason is the fixture rather than the cost: a perf suite needs its own generated, populated vault, sized through env vars, and the aggregate's small temporary vault is the wrong one. The 600 s below is a timeout, not a duration — measured end to end, most perf suites finish in seconds, and only one that generates tens of thousands of notes takes minutes.

Its CDP transport's per-eval cap is raised to 600 s as well (the budget clears it by the usual margin), because a perf suite's whole measurement is typically ONE long in-page evaluation, which the transport's 30 s default killed as a bare CDP command timed out … Runtime.evaluate naming neither the wait nor the assertion. Three plugins had each hand-written this raise in their own editContext before it moved here. Unlike a raised desktop cap, which is a backstop rather than a budget a closure may spend, this one IS a budget: no-over-cap-wait-in-eval-in-obsidian reads it for these files and for no other.

No routine command runs them, but something does: a weekly sweep runs every plugin's test:integration:desktop:performance, which is also how to reach them by hand. Adding them to that aggregate is drift, not a gap to close.
globalStubTestFilesstring[]The unit test files that redefine window, document, location or top, which the unit-tests project's VM pool cannot run.

Under pool: 'vmThreads' those four are non-configurable properties of the VM global, so vi.stubGlobal('window', …) or Object.defineProperty(window, 'location', …) throws Cannot redefine property. That is JS semantics, not a bug to route around. Every other global stays configurable and stubs normally.

Push a file here and it leaves unit-tests for a sibling unit-tests:global-stubs project that is identical except for the pool, which is the default one. A plugin's test and test:coverage scripts name unit-tests, which also selects every unit-tests:* project, so the sibling runs and is covered without a script change. It is emitted only when this list is non-empty.

To keep a whole suite on the default pool instead, set unitTests.pool to 'forks' and say why.
hookTimeoutMultiplier4The multiplier applied to a project's test budget to get its hook budget. A hook typically populates and opens a vault, so it needs several times what a single test does.
noAppObsidianPluginVitestProjectConfigThe integration-tests:no-app project, running the suites that need no Obsidian instance at all.
performanceEvalCapInMilliseconds600000The per-eval cap the performance integration project gives its CDP transport, in milliseconds.
performanceTimeoutInMillisecondsnumberThe per-test budget of the performance integration project, in milliseconds. A performance vault is pre-populated with tens of thousands of notes before Obsidian opens, so both its setup and its tests need far more time than the regular integration projects.

Like the regular budget, it CLEARS the project's per-eval cap (ObsidianPluginVitestConfigContext.performanceEvalCapInMilliseconds) rather than matching it, so an evaluation that outruns the cap reports itself instead of dying as vitest's anonymous timeout.
reportersObsidianPluginVitestReporter[]The reporters the run prints through.

Pinned rather than left to vitest, which resolves an unset reporters differently for a developer and for an AI coding session — see DEFAULT_VITEST_REPORTERS for the whole of why, and for what it deliberately leaves to vitest 5 itself.

Push onto it to add a reporter beside the pinned one.
unitTestsObsidianPluginVitestProjectConfigThe unit-tests project, running the mocked-Obsidian suites in jsdom.

Links to this page: