CdpConnection
A live connection to a CDP-enabled Obsidian instance with the runtime helper namespace bootstrapped.
Implements AsyncDisposable, so await using conn = await connectToCdp(…) disposes it (killing an owned instance and — for a throw-away temp vault — removing its directory) automatically.
Import:
import type { CdpConnection } from 'obsidian-integration-testing';Signature:
export interface CdpConnection extends AsyncDisposableExtends: AsyncDisposable
Properties
| Property | Type | Description |
|---|---|---|
| asarFallback? | AsarFallback | undefined | The silent-asar-fallback verdict for an owned instance, read live after boot: whether the app version it is actually running matches the swapped-in pin, or the installer silently reverted to its own bundled asar. undefined in attach mode, when no asar was swapped, or when the running version was unreadable. A 'fallback' verdict reaches here only when the throw is disabled (ConnectToCdpOptions.shouldThrowOnSilentAsarFallback false); otherwise it throws SilentAsarFallbackError before the connection is created. |
| cdpUrl | string | The base CDP URL, e.g. http://localhost:51888. |
| compatibility? | InstallerCompatibility | undefined | The resolved installer↔app compatibility verdict for an owned instance, when it could be determined. undefined in attach mode, or when the verdict is unknown (undetectable shell version, or the app version is absent from the table). An 'unrunnable' verdict reaches here only when the proactive throw is disabled (ConnectToCdpOptions.shouldThrowOnIncompatibleInstaller false); otherwise it throws IncompatibleInstallerVersionError before the connection is created. |
| electronCompatibility? | ElectronCompatibility | undefined | The runtime Electron compatibility verdict for an owned instance, read live after boot: whether the Electron version it is actually running is new enough for the running app version. undefined in attach mode, or when the verdict is unknown (the live version was unreadable, or the app version carries no recommended Electron version). An old Electron never blocks — it only warns — so unlike compatibility there is no throwing tier. |
| port | number | The CDP port the instance is reachable on (the free port chosen for an owned instance, or the attached ConnectToCdpOptions.port). |
| vault | TemporaryVault | The opened vault. Exposes path and populate(...) for seeding files. |
Methods
| Method | Returns | Description |
|---|---|---|
| captureScreenshot(params?) | Promise<Uint8Array> | Captures a PNG screenshot of this connection's Obsidian window, with the vault path pre-bound. Pass widthInPixels + heightInPixels to pin the viewport for the duration of the capture, so the emitted PNG is exactly that size whatever size the window happens to be. |
| dispose() | Promise<void> | Disposes the connection: kills an owned instance and removes its isolated user-data dir. The vault directory is removed only when it is a throw-away temp vault (see ConnectToCdpOptions.shouldRemoveVaultOnDispose); a real vault passed via ConnectToCdpOptions.vault is never deleted. |
| evalInObsidian(params) | Promise<Result> | Evaluates a self-contained function inside Obsidian via the rich helper path, receiving { app, lib, obsidianModule, context } plus any input (shared helpers like typeIntoEditor / waitUntil live on lib). Mirrors the top-level evalInObsidian, with the transport and vault path pre-bound to this connection. |
| invoke(expression) | Promise<string> | Evaluates a raw JavaScript expression inside Obsidian and returns the normalized string result (e.g. '5', a JSON string, or '(no output)'). |
Links to this page: