Interface MatchObject

Source
Expand description

A structured matcher. Every field you set must match for the rule to fire.

example
server.when({
model: /gpt/,
format: "openai",
system: /translator/i,
predicate: (req) => req.messages.length > 2,
}).reply("Translated output.");
interface MatchObject {
    format?: FormatName;
    message?: string | RegExp;
    model?: string | RegExp;
    predicate?: (req: MockRequest) => boolean;
    system?: string | RegExp;
    toolCallId?: string;
    toolName?: string;
}

Properties§

§readonly format?: FormatName

Only match requests from this API format.

§readonly message?: string | RegExp

Substring or regex against the last user message.

§readonly model?: string | RegExp

Substring or regex against the model name.

§readonly predicate?: { ... }

Extra predicate that runs after all other fields pass.

§readonly system?: string | RegExp

Substring or regex against the system prompt.

§readonly toolCallId?: string

Match when the last tool-result message has this tool_call_id.

§readonly toolName?: string

Match when the request includes a tool definition with this name.