Skip to content

bridgeMenu

Exposes the obsidian-typings members of Menu that the mock models under a different name, so production code reading them can be unit-tested. Without this the strict proxy throws on the read rather than returning undefined, which is what made menu.items untestable.

items is a getter over the mock’s own items__, which holds both the added items and the separators addSeparator() records — so a count read through it matches what Obsidian reports, which is what production code branching on menu.items.length depends on. Reading a MenuItem-only member off an element requires narrowing; Menu.menuItems__ does it for you.

Import:

import 'obsidian-test-mocks/obsidian-typings/setup';

Signature:

function bridgeMenu(): void

Returns: void