npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amqp-contract/testing

v0.6.0

Published

Testing utilities for AMQP contracts with testcontainers

Readme

@amqp-contract/testing

Testing utilities for AMQP contracts using testcontainers.

CI npm version npm downloads TypeScript License: MIT

📖 Full documentation →

Features

  • 🐳 Automatically starts RabbitMQ container for tests
  • ✅ Works with Vitest globalSetup
  • 🚀 Fast and reliable integration testing
  • 📊 Includes RabbitMQ management console

Installation

pnpm add -D @amqp-contract/testing

Usage

1. Configure Vitest

Add to your vitest.config.ts:

import { defineConfig } from "vitest/config";

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

2. TypeScript Support

For TypeScript projects, reference the type definitions in your tsconfig.json:

{
  "compilerOptions": {
    "types": ["@amqp-contract/testing/types/vitest"]
  }
}

Or add a triple-slash reference in your test files:

/// <reference types="@amqp-contract/testing/types/vitest" />

This provides type-safe access to the test container context variables.

3. Use Vitest Extension in Tests

The package provides a Vitest extension that automatically manages RabbitMQ connections:

import { describe, expect } from "vitest";
import { it } from "@amqp-contract/testing/extension";

describe("Order Processing", () => {
  it("should publish and consume messages", async ({ amqpConnection }) => {
    // amqpConnection is automatically provided and cleaned up
    // Your test code here using amqpConnection
  });
});

The extension provides:

  • vhost: A unique virtual host created for test isolation (automatically cleaned up after the test)
  • amqpConnectionUrl: A connection URL pre-configured with the test vhost
  • amqpConnection: An established connection to the RabbitMQ testcontainer
  • amqpChannel: A channel for AMQP operations
  • publishMessage: Helper function for publishing test messages
  • initConsumer: Helper function for setting up test consumers
  • Automatic connection and vhost cleanup after each test

What It Does

Global Setup:

  1. Starts a RabbitMQ container with management plugin
  2. Waits for RabbitMQ to be healthy
  3. Provides connection details to your tests
  4. Cleans up the container after tests complete

Test Extension:

  1. Creates a unique virtual host (vhost) for each test to ensure complete isolation
  2. Provides pre-configured connections and helpers for interacting with RabbitMQ
  3. Automatically cleans up the vhost and connections after each test completes

Container Details

  • Image: rabbitmq:3-management-alpine
  • Ports:
    • 5672 (AMQP)
    • 15672 (Management console)
  • Credentials:
    • User: guest
    • Password: guest

Environment Variables

The following variables are provided to tests:

  • __TESTCONTAINERS_RABBITMQ_IP__ - Container host IP
  • __TESTCONTAINERS_RABBITMQ_PORT_5672__ - Mapped AMQP port
  • __TESTCONTAINERS_RABBITMQ_PORT_15672__ - Mapped management port

Documentation

📖 Read the full documentation →

License

MIT