Skip to content

@amqp-contract/testing


@amqp-contract/testing / extension

extension

Vitest extension module for AMQP testing utilities

This module provides a Vitest test extension that adds AMQP-specific fixtures to your tests. Each test gets an isolated virtual host (vhost) with pre-configured connections, channels, and helper functions for publishing and consuming messages.

Type Aliases

AmqpTestFixtures

ts
type AmqpTestFixtures = object;

Defined in: extension.ts:33

The AMQP test fixtures provided by the it extension — named so helpers accepting fixture values (amqpChannel, publishMessage, …) can be typed without re-deriving the record from it.

Properties

PropertyTypeDefined in
amqpChannelChannelextension.ts:37
amqpConnectionChannelModelextension.ts:36
amqpConnectionUrlstringextension.ts:35
initConsumer(exchange, routingKey) => Promise<(options?) => Promise<amqpLib.ConsumeMessage[]>>extension.ts:43
publishMessage(target, content, options?) => voidextension.ts:38
vhoststringextension.ts:34

WaitForMessagesOptions

ts
type WaitForMessagesOptions = object;

Defined in: extension.ts:21

Options for the message-wait function returned by the initConsumer fixture.

Properties

PropertyTypeDescriptionDefined in
count?numberNumber of messages to wait for. Defaults to 1.extension.ts:23
timeoutMs?numberMaximum time in ms to wait before rejecting. Defaults to 5000.extension.ts:25

Variables

it

ts
const it: TestAPI<{
  amqpChannel: Channel;
  amqpConnection: ChannelModel;
  amqpConnectionUrl: string;
  initConsumer: (exchange, routingKey) => Promise<(options?) => Promise<ConsumeMessage[]>>;
  publishMessage: (target, content, options?) => void;
  vhost: string;
}>;

Defined in: extension.ts:49

Released under the MIT License.