This is a simple CouchDB design doc testing tool.
Usage:
var DDocTest = require('couchdb-ddoc-test');
var test = new DDocTest({
fixture: {a: 1},
src: 'path/to/map.js'
});
var result = test.runMap();
assert.equals(result, fixture);
require()
CouchDB supports require()
within design doc functions. It works slightly
different from require()
in e.g. Node.js (in which these tests are run).
Instead of relying on CouchDB’s require()
we will be using a couchapp
specific pre-processing directive. To make everything work, we have to
jump through a small hoop:
Say you want to var foo = require('foo');
within a map function. Do this:
function(doc) {
var module = module || {};
var foo = foo || require(process.cwd() + '/different/path/to/foo'
}
Test
npm test