https://github.com/expressenab/exp-fake-amqp
Stub out AMQP in tests in Node.JS apps
https://github.com/expressenab/exp-fake-amqp
Last synced: 8 months ago
JSON representation
Stub out AMQP in tests in Node.JS apps
- Host: GitHub
- URL: https://github.com/expressenab/exp-fake-amqp
- Owner: ExpressenAB
- License: mit
- Created: 2015-02-17T13:18:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-04-17T08:15:54.000Z (about 11 years ago)
- Last Synced: 2025-09-09T04:06:55.080Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 226 KB
- Stars: 1
- Watchers: 73
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
fake-amqp
=========
[](https://travis-ci.org/ExpressenAB/exp-fake-amqp)
Example usage:
```javascript
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:
```javascript
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](https://www.npmjs.com/package/exp-amqp-connection) you can use [proxyquire](https://www.npmjs.com/package/proxyquire) to replace `amqp` with `exp-fake-amqp` in your tests like this:
```javascript
var fakeAmqp = require("exp-fake-amqp");
var proxyquire = require("proxyquire");
proxyquire("exp-amqp-connection", {
amqp: fakeAmqp
});
```