Skip to content

script-utils/test-runners/integration-test-plugin

Wires the shipped integration-test harness plugin into a consumer plugin’s integration tests, so every library helper is reachable as lib.<helper> inside an evalInObsidian closure.

Two halves, and both must be wired or lib.<helper> fails:

  • getIntegrationTestPluginPopulate puts the harness plugin’s binaries in the test vault. The harness plugin is what publishes the library on window.__obsidianDevUtilsModule; in this repo’s own suite it IS the plugin-under-test, but in a consumer’s suite the plugin-under-test is the consumer’s own plugin, so the harness has to ride along as a second, test-only community plugin — seeded here, and turned on by obsidian-integration-testing’s createSetup({ enableCommunityPlugins }). - registerIntegrationTestLibResolver registers the renderer-side resolver that reads that global.

obsidian-dev-utils/integration-test-vitest-global-setup and obsidian-dev-utils/integration-test-setup are the turnkey endpoints that call these for you.

FunctionDescription
getIntegrationTestPluginPopulateBuilds the vault-relative file map that installs the shipped integration-test harness plugin, ready to hand to a global setup’s populate (or to merge into a larger map the consumer already builds). The result is a Record<string, Uint8Array>, which is assignable to obsidian-integration-testing’s PopulateFilesParams — so it composes with buildDemoVaultPopulate and friends.
registerIntegrationTestLibResolverRegisters the renderer-side resolver that merges the whole library into the lib argument of every evalInObsidian callback, reading it from the global the harness plugin publishes. Call once per test worker — the published obsidian-dev-utils/integration-test-setup endpoint does it for you when listed in setupFiles. Registration is idempotent (the harness dedupes resolvers by source text), so calling it more than once is safe.
VariableDescription
OBSIDIAN_DEV_UTILS_INTEGRATION_TEST_PLUGIN_IDThe id of the integration-test harness plugin — the folder name it is seeded into, and the value to pass to createSetup(\{ enableCommunityPlugins \}) so the harness enables it after the plugin-under-test.