Skip to content

TemporaryVault

A temporary Obsidian vault for integration tests.

Creates a temp directory and registers it in the running Obsidian instance so that the Obsidian CLI can target it via cwd.

Import:

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

Signature:

export class TemporaryVault

Constructor

new TemporaryVault(path?: string | undefined)

Creates a new temp vault.

Properties

PropertyTypeDescription
pathstringThe absolute path to the temporary vault.

Methods

MethodReturnsDescription
[Symbol.asyncDispose]()Promise<void>Async disposable support for await using.
dispose(transportOverride?)Promise<void>Unregisters the vault from Obsidian and deletes the temp directory.
populate(files)voidWrites files and folders into the vault directory. Parent directories are created automatically.

- string values are written as UTF-8 text files. - Uint8Array values (including Buffer) are written as binary files. - Paths ending with / are treated as empty folders (value must be undefined).
register(transportOverride?)Promise<void>Registers this vault in the running Obsidian instance so the CLI can target it.
syncToDevice(transportOverride?)Promise<void>Pushes all files from the local staging directory to the target device via the active transport's pushFiles().

On desktop transports this is a no-op (files are already local). On mobile transports (Appium) this pushes files to the device.

Call this after populate and before register when using a mobile transport.

Links to this page: