loadStubsFromFile

Loads stub definitions from a YAML file at path and registers them with this server.

See loadStubsFromFile for the supported YAML format.

Return

This server instance for chaining.

Parameters

path

Absolute or relative path to the YAML config file.

Throws

if the file is missing, cannot be read, or contains invalid YAML.


Loads stub definitions from a YAML file and registers them with this server.

Example file:

stubs:
- name: ping
method: GET
path: /ping
response:
body: '{"response":"Pong"}'
status: 200

- name: events
method: POST
path: /sse
response:
type: sse
chunks:
- "One"
- "Two"

Supported response types:

  • plain (default) — static body with optional status, headers, and delay

  • sse — server-sent events stream; chunks are required

  • stream — plain chunked stream; chunks are required

Return

This server instance for chaining.

Parameters

file

YAML config file.

Throws

if the file is missing, cannot be read, contains invalid YAML, or fails semantic validation (unknown method, empty chunks, etc.).