AMQP mocking and expectations library


This is a mocking and expectations library for node-amqp inspired by nock.

On your test, you can setup your mocking object like this:

    var amqp = require('amqp');
    var amqpmock = require('amqp-mock');
    var scope = amqpmock({url: 'amqp://guest:guest@localhost:5672'})
        .exchange('topic_animals', {type: 'topic'})
            .publish('', 'Hello')
            .publish('', 'World')
        .exchange('work', {type: 'fanout'})
            .publish('', 'approve', {ack: true}) // expect to be acknowledged 
            .publish('', 'disapprove', {ack: false}) // expect to be not acknowledged 
    var connection = amqp.createConnection({url: 'amqp://guest:guest@localhost:5672'});
    connection.on('ready', function(){'topic_animals', {type:'topic'}, function(exchange){
            connection.queue('', function(queue){
                queue.bind(, '*.*.rabbit');
                queue.bind(, 'lazy.#');
                queue.subscribe({ack: false}, function(message){
        });'work', {type:'fanout'}, function(exchange){
            connection.queue('', function(queue){
                queue.bind(, '');
                queue.subscribe({ack: true}, function(message){
                    if ( === 'approve')
        // This will assert that all specified calls on the scope were performed. 
    }, 10);

Since we depend on node-amqp internals and public API, node-amqp-mock version number is aligned with node-amqp version. A build number is added to specify updates.

For example, node-amqp-mock 0.1.2-3 would be the third revision compatible with node-amqp 0.1.2