Remote mocks and the client test runtime

The remote mock and the client test runtime are test tooling in the DataMind Oda source. The mock answers the web client's calls to the host side with responses that a test scripts; the runtime boots the real web client against it, in process and with no server in the loop. To choose between the test tiers, see Testing tiers.

Answer calls by endpoint

Script a stream

The call log

Boot the client against the mock

What the mock answers at startup

The mock is loaded with answers for the calls the client makes while it starts, so a fresh client boots with no sessions, no workspaces and default settings. A spec layers its own answers on top.

While starting, the client asks forThe mock answers
Its chat listAn empty list.
The default workspace setupSuccess.
Its settings descriptionWritable, with no document.
The model catalogueA default model entry.
Its preset listEmpty.
The account stateSigned out.
The follow streamDeclared as a stream, so a forgotten script reads as a stream miss.

Failures you will meet

Limits

Questions, answered

Why did my call fail with no rule for an endpoint?

The endpoint has no default or script, so the call recorded as a miss (remote-mock: no rule for <endpoint>; registered: <sorted endpoints>). Register the endpoint, or expect the call; endpoints the startup never touches stay absent, so this is also how a call into unmocked territory fails.

How do I answer an endpoint's calls?

Register a rule for the endpoint: a value returned exactly as given, or a handler that computes the answer from the call's arguments. A success answer is { ok: true, value }, a failure { ok: false, error }; re-registering the endpoint replaces its default.

How do I declare and script a stream?

Declare the endpoint as a stream before the code under test keeps a reference to its method, then register a script for its openings. The script receives the open arguments and a handle, pushes items, and the stream stays open until the test ends or fails it.

Why did a second read on my stream fail?

A stream has one consumer, so a second concurrent read is refused (remote-mock: <endpoint> stream has one consumer). Read each stream from one place; a consumer that stops early ends the stream without throwing and records it as cancelled.

Why was my send refused after the uplink ended?

The uplink was already ended (remote-mock: uplink was ended). Ending it again is a no-op, but a later send is refused; send before you end it.

Why was my item refused as not a lossless JSON value?

Every item sent over the uplink must round-trip as JSON; a value that cannot, such as a bigint, is refused. Send lossless JSON values instead.

What does clearing the mock keep?

Clearing keeps every answer and queued reply, so later calls still get them; resetting instead drops overrides and restores the initial implementation, which reads the latest registered answer.

Why did the whole-client start fail waiting for the connection?

The readiness wait ran out. The failure names the connection's state, the budget it waited, the calls that found no answer and the streams still open; add a rule for a call the startup makes, or raise connectTimeoutMs.

Why is a start refused after my test closed?

A start call made after its test closed does not run (client-test-runtime: start() called after its test fixture closed). Start within the test; teardown already disposes the client.

What does the mock answer while the client boots?

The startup answers in the table above: an empty chat list, a successful default workspace setup, a writable settings description, a default model entry, an empty preset list, a signed-out account, and the follow stream declared. The built-in events frame is what lets the client reach connected.