Skip to content

ObsidianTransport

A pluggable transport that evaluates JavaScript expressions inside a running Obsidian instance and manages vault lifecycle.

Implementations handle the platform-specific details: - DesktopCdpTransport — Desktop Obsidian via Chrome DevTools Protocol (a harness-owned isolated instance by default, or attach to a running one) - AppiumTransport — Mobile Obsidian via Appium WebView JS injection

Import:

import type { ObsidianTransport } from 'obsidian-integration-testing';

Signature:

export interface ObsidianTransport

Properties

PropertyTypeDescription
isMobilebooleanWhether this transport targets a mobile Obsidian instance.

When true, desktop-only plugins (with isDesktopOnly: true in manifest) will refuse to run integration tests.

Methods

MethodReturnsDescription
beginConsoleCapture()Promise<ConsoleCaptureHandle | undefined>Begins capturing the target's native console/error stream so a later ObsidianTransport.readConsoleCaptureSince can return everything logged since this call.

Used to surface the *real* plugin-load error when Obsidian swallows it before the harness's loadPlugin monkey-patch sees it (the error then only exists in the renderer/WebView console). Optional and platform-specific: implemented by AppiumTransport (tails adb logcat); absent on DesktopCdpTransport (desktop errors are surfaced in-renderer, and a developer can open DevTools directly).
captureScreenshot(params)Promise<Uint8Array>Captures a PNG screenshot of the running Obsidian instance.

Optional and platform-specific, like the other members here. Implemented by DesktopCdpTransport (CDP Page.captureScreenshot, optionally with the viewport pinned to an exact size) and by AppiumTransport (takeScreenshot, always the device's native framebuffer — the size knobs are ignored, so a mobile capture is sized by choosing an AVD with the wanted screen geometry).
dispose()Promise<void>Disposes of transport resources (e.g. WebSocket connections, Appium sessions).
disposeSync()voidSynchronous disposal for use in process.on('exit') handlers where async work is not possible.

Implementations should perform only synchronous cleanup here (e.g. killing child processes). Async operations like unregistering vaults are skipped.
evaluate(expression, options)Promise<string>Evaluates a JavaScript expression string inside Obsidian and returns the raw string result.

The transport normalizes the output — stripping transport-specific prefixes and handling transport-specific errors — so callers receive a clean result string (e.g. a JSON string, or (no output)).
preflightCheck(vaultPath)Promise<void>Runs transport-specific preflight checks before evaluation.

For example, the CLI transport verifies that the vault is registered, the CLI is enabled, and the CLI binary is in PATH.
pushFiles(vaultPath, files)Promise<void>Pushes files into a vault directory on the target device.

On desktop this is a no-op (files are written to the local filesystem directly). On mobile this uses the device's file transfer mechanism (e.g. Appium pushFile).
readConsoleCaptureSince(handle)Promise<string | undefined>Reads the native console/error output captured since the matching ObsidianTransport.beginConsoleCapture call.

A bounded, post-hoc, failure-path-only dump — not a live monitor.
registerVault(vaultPath)Promise<void>Registers a vault path so Obsidian can target it.

On desktop: uses Electron IPC to open the vault and polls for readiness. On mobile: pushes vault files to the device and restarts the app.
unregisterVault(vaultPath)Promise<void>Unregisters a vault path from the running Obsidian instance.

On desktop: closes the vault window and removes it from the registry. On mobile: removes vault files from the device.

Links to this page: