Lox Nexus

@lox-nexus/plugin-sdk/testing

Test helpers for plugins: PluginTestHost runs a plugin class in-process, through the same runtime as in production, without a Nexus server.

Classes

Interfaces

ConfigIssue

A problem with one setting; path leads to the field, e.g. ["devices", 2, "name"].

Properties

path

path: (string | number)[]

message

message: string


ConfigCheckResult

What a settings check answers; store only when the host passed the instance's store.

Properties

issues

issues: ConfigIssue[]

config

config: unknown

version

version: number

store?

optional store?: object

set

set: Record<string, unknown>

delete

delete: string[]


TestHostOptions

Options for PluginTestHost.start().

Properties

config?

optional config?: unknown

validated against the plugin's config schema like in production; default {}

store?

optional store?: Record<string, unknown>

what the store contains at start, as if persisted by an earlier run

instanceId?

optional instanceId?: string

default "test"

slug?

optional slug?: string

the instance's slug (Plugin.slug); default "test"

clock?

optional clock?: Clock

the plugin's clock, usually a TestClock; default the system clock

timeZone?

optional timeZone?: string

the installation's time zone the host sends (Plugin.timeZone); default none, so the server's

forwardRejections?

optional forwardRejections?: boolean

Hands this process's unhandled promise rejections to the plugin (Plugin.unhandledRejection) as the worker would, from start until stop() returns, instead of letting node:test fail the test with them. One such host at a time. Default false.

configVersion?

optional configVersion?: number

the version the config was stored with, as a host passes it; migrateConfig runs when it is older than the plugin's

hostFeatures?

optional hostFeatures?: string[]

what the host understands beyond wire version 1 (HOST_FEATURES); default all of them. Pass [] to see what an older Nexus gets: v1 panels, an action's message only, no progress or pushes.

Functions

cellText()

cellText(cell): string

A panel cell's text, for assertions on a panel: cellText(row[1]) instead of narrowing each cell. A cell with only a time gives "".

Parameters

cell

string | { text?: string; tone?: "error" | "ok" | "warn" | "info" | "muted"; until?: number; since?: number; at?: number; } | undefined

Returns

string