> ## 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.

# withChaos()

> Function exported by @botmesh/core/testing.

```ts theme={null}
function withChaos<P>(provider, options?): ChaosProvider<P>;
```

Defined in: [testing/chaos.ts:812](https://github.com/andresayac/botmesh/blob/main/packages/core/src/testing/chaos.ts#L812)

Wrap `provider` in a [ChaosProvider](https://botmesh.afaya.com.co/api/core/testing/classes/ChaosProvider.md).

## Type Parameters

| Type Parameter |
| - |
|  `P` *extends* [`IProvider`](https://botmesh.afaya.com.co/api/core/interfaces/IProvider)\<`unknown`> |

## Parameters

| Parameter | Type |
| - | - |
| `provider` | `P` |
| `options?` | [`ChaosOptions`](https://botmesh.afaya.com.co/api/core/testing/interfaces/ChaosOptions) |

## Returns

[`ChaosProvider`](https://botmesh.afaya.com.co/api/core/testing/classes/ChaosProvider)\<`P`>

## Example

```ts theme={null}
const mock = new MockProvider()
const chaos = withChaos(mock, { seed: 3, duplicates: 1 })
const bot = new Bot({ provider: chaos })
mock.incoming('hola') // delivered twice; the Bot's inbound dedupe drops the copy
```


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