songstress/testing
The mock Songstress for your tests.
See Test and debug.
What it exports is the SDK's own record of its public surface, which the SDK's tests hold to the code. Each type's fields, and every description, are read from the SDK's source when the site is built.
HookArguments · HookName · MockCall · MockHost · MockHostOptions · MockManifest · MockRequest · ProviderOf · createMockHost
HookArguments
What a hook's listeners are called with.
export type HookArguments<Name extends HookName> = ArgumentsOf<ListenerOf<ServerHooks, Name> | ListenerOf<ClientHooks, Name>>;Refers to HookName, ServerHooks, ClientHooks.
HookName
A hook's name, on either side.
export type HookName = keyof ServerHooks | keyof ClientHooks;Refers to ServerHooks, ClientHooks.
MockCall
A call the code under test made, by the member's full name ("storage.get").
Prop
Type
MockHost
The mock host, as a test holds it.
Prop
Type
Refers to MockCall, MockRequest, HookName, HookArguments, CommandContext, CommandOutcome, Providers, ProviderOf.
MockHostOptions
What a mock host is given: the manifest, the settings, the network, answers for other calls, and the side it stands in for.
Prop
Type
Refers to Side, MockManifest, SettingValue, NetRequest, Awaitable, NetResponse.
MockManifest
The parts of a manifest the mock host reads. Hand it your songstress.json as you import it, or a Manifest the validator answered.
Prop
Type
MockRequest
A request the code under test made through net.fetch.
Prop
Type
Refers to NetRequest.
ProviderOf
The provider a kind registers: ProviderOf<'lyrics'> is a LyricsProvider.
export type ProviderOf<Kind extends keyof Providers> = Providers[Kind] extends ProviderRegistry<infer Provider> ? Provider : never;Refers to Providers, ProviderRegistry.
createMockHost
Puts a mock Songstress in place, for the entry a test then imports.
export declare function createMockHost(options?: MockHostOptions): MockHost;| Parameter | Type | Description |
|---|---|---|
options? | MockHostOptions | The manifest, the settings, the network, answers for other calls, and the side. |
Returns MockHost: The mock host: fire hooks, run commands, read every call. remove() takes it away.
import { createMockHost, type MockManifest } from 'songstress/testing'
declare const manifest: MockManifest // your songstress.json, as you import it
declare const entry: string // the path of the entry under test
const host = createMockHost({ manifest })
await import(entry) // the entry registers as it loads
await host.emit(
'onScrobble',
{ id: 's1', title: 'Blue in Green', artist: 'Miles Davis' },
{ userId: 'ana', playedAt: '2026-01-01T20:00:00Z' },
)
console.log(host.calls)
host.remove()Refers to MockHostOptions, MockHost.