> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# TestChat

> Interface exported by @botmesh/core/testing.

Defined in: [testing/testChat.ts:107](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L107)

A (chat, sender) view over the test bot. See [createTestBot](https://botmesh.afaya.com.co/api/core/testing/functions/createTestBot.md).

## Properties

### ~~jid~~

```ts theme={null}
jid: string;
```

Defined in: [testing/testChat.ts:109](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L109)

#### Deprecated

Alias of [chatId](#chatid).

***

### chatId

```ts theme={null}
chatId: string;
```

Defined in: [testing/testChat.ts:111](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L111)

The chat this view drives (the user id on a DM, the group id on a group).

***

### senderId

```ts theme={null}
senderId: string;
```

Defined in: [testing/testChat.ts:113](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L113)

The simulated user (`ctx.senderId`).

***

### isGroup

```ts theme={null}
isGroup: boolean;
```

Defined in: [testing/testChat.ts:114](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L114)

***

### displayName

```ts theme={null}
displayName: string;
```

Defined in: [testing/testChat.ts:116](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L116)

Push name the simulated user shows (`ctx.senderInfo.displayName`).

## Methods

### send()

```ts theme={null}
send(text, opts?): Promise<void>;
```

Defined in: [testing/testChat.ts:119](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L119)

Simulate an inbound message from this user, then yield one macrotask so the dispatch starts.

#### Parameters

| Parameter | Type |
| - | - |
| `text` | `string` |
| `opts?` | \{ `type?`: [`MessageType`](https://botmesh.afaya.com.co/api/core/type-aliases/MessageType); } |
| `opts.type?` | [`MessageType`](https://botmesh.afaya.com.co/api/core/type-aliases/MessageType) |

#### Returns

`Promise`\<`void`>

***

### sendLocation()

#### Call Signature

```ts theme={null}
sendLocation(location): Promise<void>;
```

Defined in: [testing/testChat.ts:121](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L121)

Simulate a shared location (`ctx.sharedLocation`, `c.waitLocation()`).

##### Parameters

| Parameter | Type |
| - | - |
| `location` | [`InboundLocation`](https://botmesh.afaya.com.co/api/core/interfaces/InboundLocation) |

##### Returns

`Promise`\<`void`>

#### Call Signature

```ts theme={null}
sendLocation(
   lat, 
   lng, 
   extra?
): Promise<void>;
```

Defined in: [testing/testChat.ts:122](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L122)

##### Parameters

| Parameter | Type |
| - | - |
| `lat` | `number` |
| `lng` | `number` |
| `extra?` | `Omit`\<[`InboundLocation`](https://botmesh.afaya.com.co/api/core/interfaces/InboundLocation), `"latitude"` \| `"longitude"`> |

##### Returns

`Promise`\<`void`>

***

### sendMedia()

```ts theme={null}
sendMedia(
   kind, 
   source, 
   caption?
): Promise<void>;
```

Defined in: [testing/testChat.ts:128](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L128)

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

| Parameter | Type |
| - | - |
| `kind` | \| `"image"` \| `"video"` \| `"audio"` \| `"voice"` \| `"document"` \| `"sticker"` \| `"location"` \| `"contact"` |
| `source` | [`MockMediaSource`](https://botmesh.afaya.com.co/api/core/testing/type-aliases/MockMediaSource) |
| `caption?` | `string` \| [`MockMediaOptions`](https://botmesh.afaya.com.co/api/core/testing/interfaces/MockMediaOptions) |

#### Returns

`Promise`\<`void`>

***

### sendReaction()

```ts theme={null}
sendReaction(emoji, target?): Promise<void>;
```

Defined in: [testing/testChat.ts:133](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L133)

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

| Parameter | Type |
| - | - |
| `emoji` | `string` |
| `target?` | \| [`MessageRef`](https://botmesh.afaya.com.co/api/core/interfaces/MessageRef) \| \{ `to?`: [`MessageRef`](https://botmesh.afaya.com.co/api/core/interfaces/MessageRef); `removed?`: `boolean`; } |

#### Returns

`Promise`\<`void`>

***

### sendInteraction()

```ts theme={null}
sendInteraction(data, opts?): Promise<void>;
```

Defined in: [testing/testChat.ts:135](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L135)

Simulate a raw interaction (`provider.interaction`): `data` is what `ctx.body` / `ctx.interaction.data` carry.

#### Parameters

| Parameter | Type |
| - | - |
| `data` | `string` |
| `opts?` | \{ `kind?`: `"list"` \| `"button"` \| `"command"` \| `"modal"` \| `"autocomplete"`; `id?`: `string`; } |
| `opts.kind?` | `"list"` \| `"button"` \| `"command"` \| `"modal"` \| `"autocomplete"` |
| `opts.id?` | `string` |

#### Returns

`Promise`\<`void`>

***

### pressButton()

```ts theme={null}
pressButton(target): Promise<PressedButton>;
```

Defined in: [testing/testChat.ts:141](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L141)

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

| Parameter | Type |
| - | - |
| `target` | `string` \| `number` |

#### Returns

`Promise`\<[`PressedButton`](https://botmesh.afaya.com.co/api/core/testing/interfaces/PressedButton)>

***

### expectReply()

```ts theme={null}
expectReply(matcher, timeoutMs?): Promise<string>;
```

Defined in: [testing/testChat.ts:144](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L144)

Resolve with the first reply matching `matcher` (already sent or arriving before the timeout).

#### Parameters

| Parameter | Type |
| - | - |
| `matcher` | `string` \| `RegExp` |
| `timeoutMs?` | `number` |

#### Returns

`Promise`\<`string`>

***

### expectNoReply()

```ts theme={null}
expectNoReply(opts?): Promise<void>;
```

Defined in: [testing/testChat.ts:149](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L149)

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

| Parameter | Type |
| - | - |
| `opts?` | \| `number` \| \{ `timeout?`: `number`; } |

#### Returns

`Promise`\<`void`>

***

### replies()

```ts theme={null}
replies(): string[];
```

Defined in: [testing/testChat.ts:152](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L152)

Snapshot of all text/caption replies sent to this chat so far (buttons and lists: their text).

#### Returns

`string`\[]

***

### sent()

```ts theme={null}
sent(): TestSent[];
```

Defined in: [testing/testChat.ts:154](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L154)

Every message the bot sent to this chat, with its full content and `ref`.

#### Returns

[`TestSent`](https://botmesh.afaya.com.co/api/core/testing/interfaces/TestSent)\[]

***

### lastReply()

```ts theme={null}
lastReply(): TestSent | undefined;
```

Defined in: [testing/testChat.ts:156](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L156)

The last message the bot sent to this chat.

#### Returns

[`TestSent`](https://botmesh.afaya.com.co/api/core/testing/interfaces/TestSent) | `undefined`

***

### transcript()

#### Call Signature

```ts theme={null}
transcript(opts): string;
```

Defined in: [testing/testChat.ts:163](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L163)

The exchange so far as a golden [Transcript](https://botmesh.afaya.com.co/api/core/interfaces/Transcript.md) (same shape `recordTranscript`
produces: it parses, redacts and replays with `assertTranscript`). Deterministic by
default (no ids, no timestamps), so it fits `toMatchSnapshot()`.

##### Parameters

| Parameter | Type |
| - | - |
| `opts` | [`TestTranscriptOptions`](https://botmesh.afaya.com.co/api/core/testing/interfaces/TestTranscriptOptions) & `object` |

##### Returns

`string`

#### Call Signature

```ts theme={null}
transcript(opts?): Transcript;
```

Defined in: [testing/testChat.ts:164](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L164)

##### Parameters

| Parameter | Type |
| - | - |
| `opts?` | [`TestTranscriptOptions`](https://botmesh.afaya.com.co/api/core/testing/interfaces/TestTranscriptOptions) |

##### Returns

[`Transcript`](https://botmesh.afaya.com.co/api/core/interfaces/Transcript)

***

### as()

```ts theme={null}
as(userId, opts?): TestChat;
```

Defined in: [testing/testChat.ts:167](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/testChat.ts#L167)

Same chat seen by another participant (groups). On a DM: another DM with the same bot.

#### Parameters

| Parameter | Type |
| - | - |
| `userId` | `string` |
| `opts?` | \{ `displayName?`: `string`; } |
| `opts.displayName?` | `string` |

#### Returns

`TestChat`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.