amqpx / extensions/vitest / TestQueue
Class: TestQueue
Defined in: src/extensions/vitest/test-queue.ts:22
Mock implementation of Queue using vitest mocks.
All create* methods return test instance of classes from this package. assert and bindExchange methods are vitest mocks returning current instance.
Example
ts
import { TestQueue } from 'amqpx/vitest';
const queue = new TestQueue();
// or create from TestChannel, TestConnection, or TestExchange
expect(queue.bindExchange).toBeCalledTimes(0);Implements
Constructors
Constructor
new TestQueue():
TestQueue
Returns
TestQueue
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
assert | Mock<Procedure> | Verify the queue against the broker, according to the configured assertionMode. - Assert (default) — declare the queue; creates it if absent, throws on config mismatch. - Check — verify the queue exists without creating it; throws if absent. - Passive — no-op; no network call is made. Subsequent calls return immediately once the first call completes successfully. Returns this to allow chaining. | src/extensions/vitest/test-queue.ts:23 |
bindExchange | Mock<Procedure> | Bind this queue to an exchange. Asserts the queue first if it has not been asserted yet. Param Exchange to bind this queue to. Param Routing key pattern under which to bind. Param Optional AMQP headers or x-arguments for the binding. | src/extensions/vitest/test-queue.ts:27 |
createBatchConsumer | Mock<Procedure> | Create batch consumer for current queue. By default, creates a new dedicated channel for the consumer. Pass a channel in options to use a specific one instead. | src/extensions/vitest/test-queue.ts:33 |
createConsumer | Mock<Procedure> | Create consumer for current queue. By default, creates a new dedicated channel for the consumer. Pass a channel in options to use a specific one instead. | src/extensions/vitest/test-queue.ts:29 |
createProducer | Mock<Procedure> | Create producer for current queue. Publishes via the default RabbitMQ exchange, routing messages directly to this queue by name. By default, creates a new dedicated channel for the producer. Pass a channel in options to use a specific one instead. Param Optional producer options (serialization, routing key, hooks, …). Set options.isConfirmed to true to open the dedicated channel in confirm mode. Has no effect when options.channel is supplied. | src/extensions/vitest/test-queue.ts:37 |
name | Mock<Procedure> | Returns the name of the queue. Asserts the queue first if it has not been asserted yet. | src/extensions/vitest/test-queue.ts:25 |