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 ObsidianTransportProperties
| Property | Type | Description |
|---|---|---|
| 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: CaptureScreenshotParams) => 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? | () => void | Synchronous 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: string, options: TransportEvalOptions) => 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)). |
| isMobile | boolean | Whether this transport targets a mobile Obsidian instance. When true, desktop-only plugins (with isDesktopOnly: true in manifest) will refuse to run integration tests. |
| preflightCheck | (vaultPath: string) => 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: string, files: Record<string, Uint8Array>) => 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: ConsoleCaptureHandle | undefined) => 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: string) => 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 only a minimal .obsidian marker so the folder is recognized as a vault, points the app's localStorage at it, and reloads.It does **not** carry the vault's contents across on either platform — that is ObsidianTransport.pushFiles' job, which TemporaryVault.register runs first. A caller driving a transport directly has to push before registering, or the app opens an empty vault with nothing raised to say so. |
| unregisterVault | (vaultPath: string) => 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:
- AppConfigRestore
- GetAppConfigParams
- SetAppConfigParams
- WithAppConfigParams
- ApplyObsidianThemeParams
- AssertObsidianThemeUnchangedParams
- CaptureObsidianScreenshotOptions
- EvalInObsidianParams
- HideCaretOptions
- HideVaultNameOptions
- OpenObsidianSettingsTabParams
- PinWindowFocusOptions
- PollInObsidianParams
- AppiumTransport
- DesktopCdpTransport
- createTransportFromOptions
- registerVault
- unregisterVault