@vestra-player/sdk - v1.11.3
    Preparing search index...

    Module @vestra-player/sdk/testing

    Test tools for Vestra Player plugins: an in-memory fake player (TestHost) and startPlugin, which activates a plugin against it.

    TestHost speaks the real wire protocol, so the SDK's own logic (revisions, conditional commits, recovery after lost replies, coalescing of updates) runs exactly as it does inside the player. Only the player side is faked, and its semantics are simplified:

    • no media decoding: sources are facts you set with TestHost.setSource or TestHost.openElsewhere;
    • no Slint and no native windows: views are records of their properties and callbacks (FakeWindow), and you fire callbacks yourself;
    • export jobs advance one step on every state query (queued → running → completed);
    • video and audio processing nodes are validated with the player's own value ranges (an out-of-range filter.set ends in failed with invalid), an empty chain removes the plugin's chain, a chain on a generated stream fails unsupported (the player's own conformance cases check all three), and the command limits (COMMAND_LIMITS), property value limits (UI_VALUE_LIMITS) and menu ids (MENU_IDS) are enforced.

    Typical workflow: start the plugin with startPlugin (it reads the plugin's manifest.json), drive it the way the user or another plugin would (run commands, press bindings, fire view callbacks, change the source), wait with TestHost.settle, assert on what the host recorded (host.osd, host.window(id).props, host.sent(method), …), and finally call stop().

    Use it from node:test (what vestra-plugin test runs). Each test should create its own host; stop() removes the host's temporary directories.

    A complete test file: it activates the plugin against an in-memory player, picks its Hello menu item and checks what the OSD showed. startPlugin reads the plugin's manifest.json from directory, calls activate and waits for its registrations; run() executes the command as the menu would and waits until the host is idle. stop() disposes the plugin and removes the host's temporary files, even when an assertion fails.

    // tests/main.test.ts
    import assert from "node:assert/strict";
    import test from "node:test";
    import { startPlugin } from "@vestra-player/sdk/testing";
    import activate from "../main.ts";

    test("the Hello command shows a message", async () => {
    const { host, stop } = await startPlugin(activate, {
    directory: new URL("..", import.meta.url),
    });
    try {
    assert.equal(host.command("hello").state.enabled, true);
    await host.command("hello").run();
    assert.deepEqual(host.osd, ["Hello"]);
    } finally {
    await stop();
    }
    });
    COMMAND_LIMITS
    BAR_BUTTON_ICONS
    BAR_BUTTON_LIMITS
    BuiltinSubmenu
    BUILTIN_SUBMENUS
    BuiltinCommand
    BUILTIN_COMMANDS
    LOCALES
    LIST_SEPARATORS
    TEXT_LIMITS
    THEME_PALETTES
    BINDING_INPUTS
    OSD_LIMITS
    SESSION_STORAGE_LIMITS
    SECRET_LIMITS
    SUBTITLE_LIMITS
    FakeWindow
    FileDialogText
    FakeCommand
    FakeBarButton
    FakeProducer
    MarkdownWire
    FakePanel
    TestHost
    startPlugin
    KeptTrigger
    TIMELINE_LIMITS
    TRIGGER_LIMITS
    UI_VALUE_LIMITS
    IMAGE_LIMITS
    VIDEO_PROCESSING_LIMITS
    MESSAGE_LIMIT
    HostError