Skip to content

API reference / @chanx-js/server / testing / TestClient

Interface: TestClient ​

Defined in: packages/server/src/testing.ts:31

A client connected in-process by connect().

Properties ​

closed ​

ts
readonly closed: Promise<{
  code?: number;
  reason?: string;
}>;

Defined in: packages/server/src/testing.ts:57

Resolves when the server closes the socket.


pending ​

ts
readonly pending: readonly Frame[];

Defined in: packages/server/src/testing.ts:35

Frames received and not yet consumed by receive().


ready ​

ts
readonly ready: Promise<boolean>;

Defined in: packages/server/src/testing.ts:33

Resolves once the server has connected this client: authenticated, groups joined.

Methods ​

close() ​

ts
close(): Promise<void>;

Defined in: packages/server/src/testing.ts:55

Close from the client side; resolves once the server has torn the connection down.

Returns ​

Promise<void>


receive() ​

ts
receive(options?): Promise<Frame>;

Defined in: packages/server/src/testing.ts:41

The next frame from the server, within a second unless told otherwise.

Parameters ​

ParameterType
options?WaitOptions

Returns ​

Promise<Frame>


receiveAll() ​

ts
receiveAll(options?): Promise<Frame[]>;

Defined in: packages/server/src/testing.ts:47

Every frame that arrives until none has for timeout ms (default 100).

Parameters ​

ParameterType
options?WaitOptions

Returns ​

Promise<Frame[]>


receiveNothing() ​

ts
receiveNothing(options?): Promise<boolean>;

Defined in: packages/server/src/testing.ts:49

Whether no frame arrives within timeout ms (default 100).

Parameters ​

ParameterType
options?WaitOptions

Returns ​

Promise<boolean>


receiveUntil() ​

ts
receiveUntil(action?, options?): Promise<Frame[]>;

Defined in: packages/server/src/testing.ts:45

Collect frames until one with this action arrives, that one included.

Parameters ​

ParameterType
action?string
options?WaitOptions

Returns ​

Promise<Frame[]>


request() ​

ts
request(message, options?): Promise<Frame>;

Defined in: packages/server/src/testing.ts:43

Send a message with a fresh ref and resolve with the reply that echoes it.

Parameters ​

ParameterType
messageobject
options?WaitOptions & object

Returns ​

Promise<Frame>


send() ​

ts
send(frame): void;

Defined in: packages/server/src/testing.ts:37

Send a raw frame, as it goes on the wire.

Parameters ​

ParameterType
frameobject

Returns ​

void


sendMessage() ​

ts
sendMessage(message, options?): void;

Defined in: packages/server/src/testing.ts:39

Send a message as .create() builds it, with a ref or topic when given.

Parameters ​

ParameterType
messageMessage
options?{ ref?: string; topic?: string; }
options.ref?string
options.topic?string

Returns ​

void


subscribe() ​

ts
subscribe(topic, options?): Promise<Frame>;

Defined in: packages/server/src/testing.ts:51

Subscribe to a topic; resolves with the server's reply.

Parameters ​

ParameterType
topicstring
options?WaitOptions

Returns ​

Promise<Frame>


unsubscribe() ​

ts
unsubscribe(topic, options?): Promise<Frame>;

Defined in: packages/server/src/testing.ts:53

Unsubscribe from a topic; resolves with the server's reply.

Parameters ​

ParameterType
topicstring
options?WaitOptions

Returns ​

Promise<Frame>

MIT licensed