A nock helper library for mocking a CouchDB server
NOTE: this library is under heavy development right now, and is missing a lot of features, but feel free to monitor the issues/milestones for progress updates.
$ npm install nock-couchdbMost calls in this API use nock to add an interceptor for a given HTTP request reflected by the server/database/document meta.
var assert = require('assert');
var couchdb = require('nock-couchdb');
var supertest = require('supertest');
var url = 'http://localhost:5984/';
var server = couchdb.server(url);
var request = supertest(url);
describe('...', function () {
it('...', function (done) {
server
.database('db')
.document('doc')
.get({ hello: 'world' }); // adds a nock interceptor
request
.get('doc/db')
.expect(200)
.expect(function (res) {
assert.equal(res.body.hello, 'world');
})
.end(done);
});
});The top-level interface, which reflects a CouchDB server. The specified
href points to the CouchDB root. (default: http://localhost:5984/)
Part of the chainable interface, but reflects a specific database within the parent server.
Part of the chainable interface, but reflects a specific document within the parent database/server.
| Parameter | Type | Description |
|---|---|---|
| data | Object |
Customizes the response body |
Sets up a mock for the server API root.
| Parameter | Type | Description |
|---|---|---|
| data | Object |
Customizes the response body |
Sets up a mock for the database API root.
| Parameter | Type | Description |
|---|---|---|
| data | Object |
Customizes the response body |
Sets up a mock for retrieving the document.