Skip to content

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.

Import:

import { captureObsidianScreenshot } from 'obsidian-integration-testing';

Signature:

function captureObsidianScreenshot(options: CaptureObsidianScreenshotOptions | undefined): Promise<Uint8Array<ArrayBufferLike>>

Parameters:

Parameter Type Description
options CaptureObsidianScreenshotOptions | undefined Optional size, transport and vault overrides.

Returns: Promise<Uint8Array<ArrayBufferLike>> — A Promise that resolves to the raw PNG bytes.


Links to this page: