Skip to content
Obsidian Test Mocks logo

Obsidian Test Mocks

Comprehensive test mocks for the Obsidian plugin API.

The whole public API

In-memory implementations of every class and function in obsidian.d.ts, tracked against each new Obsidian release.

Globals and prototypes

The extensions Obsidian installs on DOM and JS builtins — createDiv, el.setText, Array.prototype.contains — installed and torn down for you.

Strict by default

Reading a property nobody mocked throws a descriptive error instead of returning undefined, so a test cannot pass for the wrong reason.

Spyable everywhere

All construction routes through create__() factories and constructor__() hooks, so vi.spyOn() reaches it.

Vitest and Jest

One-line setup entry points for both, plus a framework-agnostic setup() / teardown() pair for everything else.

100% covered

Lines, branches, functions and statements — enforced on every build.