Skip to content

amqpx v1.0.1


amqpx / extensions/jest / TestQueue

Class: TestQueue

Defined in: src/extensions/jest/test-queue.ts:22

Mock implementation of Queue using jest mocks.

All create* methods return test instance of classes from this package. assert and bindExchange methods are jest mocks returning current instance.

Example

ts
import { TestQueue } from 'amqpx/jest';

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

PropertyTypeDescriptionDefined in
assertMock<any, any, any>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/jest/test-queue.ts:23
bindExchangeMock<any, any, any>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/jest/test-queue.ts:27
createBatchConsumerMock<any, any, any>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/jest/test-queue.ts:33
createConsumerMock<any, any, any>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/jest/test-queue.ts:29
createProducerMock<any, any, any>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/jest/test-queue.ts:37
nameMock<any, any, any>Returns the name of the queue. Asserts the queue first if it has not been asserted yet.src/extensions/jest/test-queue.ts:25

Released under the MIT License.