Skip to main content
Defined in: testing/testChat.ts:107 A (chat, sender) view over the test bot. See createTestBot.

Properties

jid

Defined in: testing/testChat.ts:109

Deprecated

Alias of chatId.

chatId

Defined in: testing/testChat.ts:111 The chat this view drives (the user id on a DM, the group id on a group).

senderId

Defined in: testing/testChat.ts:113 The simulated user (ctx.senderId).

isGroup

Defined in: testing/testChat.ts:114

displayName

Defined in: testing/testChat.ts:116 Push name the simulated user shows (ctx.senderInfo.displayName).

Methods

send()

Defined in: testing/testChat.ts:119 Simulate an inbound message from this user, then yield one macrotask so the dispatch starts.

Parameters

Returns

Promise<void>

sendLocation()

Call Signature

Defined in: testing/testChat.ts:121 Simulate a shared location (ctx.sharedLocation, c.waitLocation()).
Parameters
Returns
Promise<void>

Call Signature

Defined in: testing/testChat.ts:122
Parameters
Returns
Promise<void>

sendMedia()

Defined in: testing/testChat.ts:128 Simulate an inbound media message: ctx.body is the caption, loadMediaOf(ctx) resolves with the bytes. A { url } source without bytes makes the download reject with MediaUnavailableError (the mock never touches the network).

Parameters

Returns

Promise<void>

sendReaction()

Defined in: testing/testChat.ts:133 Simulate a reaction (bot.on('reaction'), 'reaction' hooks). Default target: the bot’s last message in this chat, else the user’s last message. { removed: true } retracts it.

Parameters

Returns

Promise<void>

sendInteraction()

Defined in: testing/testChat.ts:135 Simulate a raw interaction (provider.interaction): data is what ctx.body / ctx.interaction.data carry.

Parameters

Returns

Promise<void>

pressButton()

Defined in: testing/testChat.ts:141 Press a native button, list row or card button of the LAST interactive message the bot sent to this chat: by id, by title (case-insensitive) or 1-based index. The bot receives what a real press produces (a 'buttons' message whose body is the id).

Parameters

Returns

Promise<PressedButton>

expectReply()

Defined in: testing/testChat.ts:144 Resolve with the first reply matching matcher (already sent or arriving before the timeout).

Parameters

Returns

Promise<string>

expectNoReply()

Defined in: testing/testChat.ts:149 Resolve when no reply beyond the ones already consumed exists now nor arrives within timeout (default 300 ms); reject listing the unexpected replies. Consumes nothing.

Parameters

Returns

Promise<void>

replies()

Defined in: testing/testChat.ts:152 Snapshot of all text/caption replies sent to this chat so far (buttons and lists: their text).

Returns

string[]

sent()

Defined in: testing/testChat.ts:154 Every message the bot sent to this chat, with its full content and ref.

Returns

TestSent[]

lastReply()

Defined in: testing/testChat.ts:156 The last message the bot sent to this chat.

Returns

TestSent | undefined

transcript()

Call Signature

Defined in: testing/testChat.ts:163 The exchange so far as a golden Transcript (same shape recordTranscript produces: it parses, redacts and replays with assertTranscript). Deterministic by default (no ids, no timestamps), so it fits toMatchSnapshot().
Parameters
Returns
string

Call Signature

Defined in: testing/testChat.ts:164
Parameters
Returns
Transcript

as()

Defined in: testing/testChat.ts:167 Same chat seen by another participant (groups). On a DM: another DM with the same bot.

Parameters

Returns

TestChat