[**@amqp-contract/testing**](index.md)

***

[@amqp-contract/testing](index.md) / global-setup

# global-setup

Global setup module for starting RabbitMQ test containers

This module provides a Vitest globalSetup function that automatically starts
a RabbitMQ container with the management plugin before tests run, and stops
it after all tests complete.

The RabbitMQ image can be configured via the `RABBITMQ_IMAGE` environment variable.
By default, it uses the public Docker Hub image (`rabbitmq:4.2.1-management-alpine`).

## Functions

### default()

```ts
function default(provide): Promise<() => Promise<void>>;
```

Defined in: [global-setup.ts:58](https://github.com/btravstack/amqp-contract/blob/1948ac0d26ba5aafc2d473bf2820eb2e5408fd7a/packages/testing/src/global-setup.ts#L58)

Setup function for Vitest globalSetup

Starts a RabbitMQ container before all tests and provides connection details
to tests via Vitest's provide API. The container is automatically stopped
and cleaned up after all tests complete.

This function should be configured in your `vitest.config.ts`:

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `provide` | `TestProject` | Function to provide context values to tests |

#### Returns

`Promise`&lt;() => `Promise`&lt;`void`&gt;&gt;

Cleanup function that stops the RabbitMQ container

#### Example

```typescript
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    globalSetup: ["@amqp-contract/testing/global-setup"],
  },
});
```
