Pular para o conteúdo
Português (BR)

TestProbe

Este conteúdo não está disponível em sua língua ainda.

Defined in: src/testkit/TestProbe.ts:24

A lightweight ActorRef that captures every tell for inspection by tests. Unlike an ordinary actor it is synchronous and not driven by the dispatcher — messages sit in an internal queue until a test asserts on them.

new TestProbe(system, opts?): TestProbe

Defined in: src/testkit/TestProbe.ts:38

ActorSystem

TestProbeOptions = {}

TestProbe

ActorRef.constructor

readonly path: ActorPath

Defined in: src/testkit/TestProbe.ts:25

ActorRef.path

get messageCount(): number

Defined in: src/testkit/TestProbe.ts:58

Number of messages currently buffered.

number


get sender(): ActorRef<unknown> | null

Defined in: src/testkit/TestProbe.ts:64

The sender of the LAST message consumed via expect* / receive*.

ActorRef<unknown> | null

ask<TRes>(message, timeoutMs?): Promise<TRes>

Defined in: src/ActorRef.ts:43

Request/response — send message and await the recipient’s reply. The framework synthesises a one-shot reply ref, injects it as both the sender slot and as message.replyTo, and resolves the returned promise with the first reply (or rejects with AskTimeoutError).

The caller never specifies replyTo on the message — the OmitReplyTo type subtracts it from the parameter type if the recipient declares it.

const value = await counter.ask<number>({ kind: 'get' });

TRes = unknown

unknown

number = 5_000

Promise<TRes>

ActorRef.ask


clearInbox(): void

Defined in: src/testkit/TestProbe.ts:73

Clear all buffered messages — handy between test phases.

void


equals(other): boolean

Defined in: src/ActorRef.ts:67

ActorRef

boolean

ActorRef.equals


expectMsg<T>(expected, timeoutMs?): Promise<T>

Defined in: src/testkit/TestProbe.ts:90

Assert the next message deep-equals expected.

T

T

number

Promise<T>


expectMsgType<T>(Class, timeoutMs?): Promise<T>

Defined in: src/testkit/TestProbe.ts:99

Assert the next message is an instance of Class.

T

(…args) => T

number

Promise<T>


expectNoMessage(timeoutMs?): Promise<void>

Defined in: src/testkit/TestProbe.ts:111

Assert NO message arrives within the timeout.

number = 300

Promise<void>


fishForMessage<T>(pred, timeoutMs?): Promise<T>

Defined in: src/testkit/TestProbe.ts:138

Receive messages until pred returns true. Other messages are discarded.

T

(m) => boolean

number = ...

Promise<T>


hasMessage(): boolean

Defined in: src/testkit/TestProbe.ts:61

True when there is at least one buffered message waiting to be consumed.

boolean


kill(): void

Defined in: src/ActorRef.ts:63

Kill this actor — raises ActorKilledError through the normal supervision path.

void

ActorRef.kill


receiveN(n, timeoutMs?): Promise<unknown[]>

Defined in: src/testkit/TestProbe.ts:83

Receive the next n messages.

number

number

Promise<unknown[]>


receiveOne(timeoutMs?): Promise<unknown>

Defined in: src/testkit/TestProbe.ts:78

Wait for the next message and return it. Throws on timeout.

number

Promise<unknown>


reply(message): void

Defined in: src/testkit/TestProbe.ts:67

Convenience: reply to the last sender (throws if there is none).

unknown

void


send(message): void

Defined in: src/ActorRef.ts:30

Alias for tell — useful if you want to pipe something.

unknown

void

ActorRef.send


stop(): void

Defined in: src/ActorRef.ts:60

Gracefully stop this actor after it drains its mailbox.

void

ActorRef.stop


tell(message, sender?): void

Defined in: src/testkit/TestProbe.ts:45

Send a message to this actor. sender is surfaced as context.sender in the recipient.

unknown

ActorRef<unknown> | null

void

ActorRef.tell


toString(): string

Defined in: src/ActorRef.ts:65

string

ActorRef.toString