capture-obsidian-screenshot
Captures a screenshot of the Obsidian instance the current test context is already driving.
The transport-level captureScreenshot needs a transport in hand, which a test running under the harness’s global setup never has — the instance is owned by that setup and reached through the context provider. This is the context-resolving entry point, the screenshot counterpart of evalInObsidian / pollInObsidian: with no arguments at all it captures whatever instance the active project is driving, desktop or mobile.
It also makes the frame REPRODUCIBLE before taking it, by hiding the vault’s name — see hide-vault-name.ts for why a temp-vault-<random> bleeds through the caption band and rewrites a checked-in PNG on every run — and by hiding the focused element’s blinking caret for the length of the capture — see hide-caret.ts for why that is a transparent caret and not a blur — and by drawing the window focused whether or not the OS gave it focus — see pin-window-focus.ts for the title bar that otherwise darkens one run in five.
And it refuses a frame whose theme has changed since applyObsidianTheme set it — see apply-obsidian-theme.ts for the config reload that silently turns a dark capture run light.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| CaptureObsidianScreenshotOptions | Options for captureObsidianScreenshot. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| captureObsidianScreenshot | Captures a PNG screenshot of the running Obsidian instance, resolving the transport and vault from the current test context. The vault’s name is hidden first, so two runs of the same suite against two differently-named temporary vaults produce byte-identical PNGs. Pass CaptureObsidianScreenshotOptions.shouldHideVaultName as false to photograph it. The focused element’s caret is hidden for the capture too, and restored after it, so a frame with a focused field does not alternate between two blink phases; CaptureObsidianScreenshotOptions.shouldHideCaret turns that off. The window is drawn focused whether or not the OS gave it focus; CaptureObsidianScreenshotOptions.shouldPinWindowFocus turns that off. A frame whose body has left the theme applyObsidianTheme applied is refused; CaptureObsidianScreenshotOptions.shouldVerifyTheme turns that off. |