Skip to content

@amqp-contract/testing


@amqp-contract/testing / 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<void>;

Defined in: packages/testing/src/global-setup.ts:58

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

ParameterTypeDescription
provideTestProjectFunction to provide context values to tests

Returns

Promise<void>

Cleanup function that stops the RabbitMQ container

Example

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

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

Released under the MIT License.