Skip to content

ExpressenAB/exp-fake-amqp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fake-amqp

Build Status

Example usage:

var fakeAmqp = require("exp-fake-amqp");

connection = fakeAmqp.createConnection();
var exchange = connection.exchange("testExchange", {});
connection.queue("theQueue", {}, function (queue) {
  queue.bind("testExchange", "route", function () {
    queue.subscribe(function (message) {
      console.log(message);
    });
    exchange.publish("route", "hello!", {});
  });
});

For further examples see the tests.

Overriding AMQP

You might want to override amqp with fake-amqp in tests. This can be done this way:

var amqp = require("amqp");
var fakeAmqp = require("exp-fake-amqp");

amqp.Connection = fakeAmqp.Connection;
amqp.createConnection = fakeAmqp.createConnection;

If you are using exp-amqp-connection you can use proxyquire to replace amqp with exp-fake-amqp in your tests like this:

var fakeAmqp = require("exp-fake-amqp");
var proxyquire = require("proxyquire");

proxyquire("exp-amqp-connection", {
  amqp: fakeAmqp
});

About

Stub out AMQP in tests in Node.JS apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published