couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gar...@apache.org
Subject couchdb-nmo git commit: Convert from Lab.js to Mocha
Date Mon, 04 Jan 2016 15:01:24 GMT
Repository: couchdb-nmo
Updated Branches:
  refs/heads/master 7a27f3246 -> 2efbd3407


Convert from Lab.js to Mocha

Convert all tests from Lab.js to Mocha.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/commit/2efbd340
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/tree/2efbd340
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-nmo/diff/2efbd340

Branch: refs/heads/master
Commit: 2efbd3407925b19fa391d994a167d78e90b55ee7
Parents: 7a27f32
Author: Garren Smith <garren.smith@gmail.com>
Authored: Tue Dec 8 15:45:55 2015 +0200
Committer: Garren Smith <garren.smith@gmail.com>
Committed: Mon Jan 4 16:50:30 2016 +0200

----------------------------------------------------------------------
 .eslintrc              |   3 +-
 .jshintignore          |   1 -
 .jshintrc              |  18 ----
 package.json           |   7 +-
 src/couch-config.js    |   7 +-
 test/activetasks.js    |  91 ++++++++----------
 test/cluster.js        | 147 +++++++++++-----------------
 test/config.js         | 228 ++++++++++++++++++--------------------------
 test/couch-config.js   | 201 ++++++++++++++++----------------------
 test/help.js           |  33 +++----
 test/helpers.js        |  17 ++++
 test/import-csv.js     |  51 ++++------
 test/isonline.js       | 139 ++++++++++-----------------
 test/nemo.js           |  19 ++--
 test/replicate-from.js |  35 +++----
 test/replicate-to.js   |  38 +++-----
 test/replicate.js      |  26 ++---
 test/savetofile.js     |  52 ++++------
 test/utils.js          |  84 +++++++---------
 test/v.js              |  40 +++-----
 20 files changed, 479 insertions(+), 758 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/.eslintrc
----------------------------------------------------------------------
diff --git a/.eslintrc b/.eslintrc
index 25e0930..32d133c 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -1,7 +1,8 @@
 {
   "parser": "babel-eslint",
   "env": {
-    "node": true
+    "node": true,
+    "mocha": true
   },
   "rules": {
     "quotes": [2, "single"],

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/.jshintignore
----------------------------------------------------------------------
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index cf70988..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1 +0,0 @@
-**/node_modules

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/.jshintrc
----------------------------------------------------------------------
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 9d53e17..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  "node": true,
-  "couch": true,
-  "esnext": true,
-  "bitwise": true,
-  "camelcase": true,
-  "curly": true,
-  "immed": true,
-  "newcap": true,
-  "noarg": true,
-  "undef": true,
-  "unused": "vars",
-  "nonbsp": true,
-  "expr": true,
-  "esnext": true,
-  "globals": {
-  }
-}

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 3b84b10..ff8c93e 100644
--- a/package.json
+++ b/package.json
@@ -7,8 +7,8 @@
   "scripts": {
     "transpile": "babel src -d lib",
     "prepublish": "make && npm run transpile",
-    "test": "npm run lint && lab -v --transform node_modules/lab-babel -S -I core,_babelPolyfill,regeneratorRuntime,__core-js_shared__,Reflect",
-    "lint": "eslint ./src ./test"
+    "test": "npm run lint && ./node_modules/.bin/mocha --compilers js:babel-register ./test/*.js",
+    "lint": "eslint ./src ./test ./bin"
   },
   "author": "Robert Kowalski <rok@kowalski.gd>",
   "license": "Apache 2.0",
@@ -47,10 +47,9 @@
     "babel-eslint": "^4.1.5",
     "babel-polyfill": "^6.2.0",
     "eslint": "^1.9.0",
-    "lab": "~5.5.1",
-    "lab-babel": "1.0.0",
     "less": "~2.5.0",
     "marked-man": "~0.1.4",
+    "mocha": "^2.3.4",
     "nock": "^3.3.2",
     "node-doc-generator": "robertkowalski/node-documentation-generator#sloppy"
   }

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/src/couch-config.js
----------------------------------------------------------------------
diff --git a/src/couch-config.js b/src/couch-config.js
index 7c82eca..5379b94 100644
--- a/src/couch-config.js
+++ b/src/couch-config.js
@@ -58,8 +58,11 @@ export function get (cluster, nodes, section) {
     }
 
     Object.keys(nodeConfigs).forEach(node => {
-      console.log('NODE:', node);
-      console.log(prettyjson.render(nodeConfigs[node], {}));
+      var msg = [
+        'NODE:',
+        prettyjson.render(nodeConfigs[node], {})
+      ].join('\n');
+      console.log(msg);
     });
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/activetasks.js
----------------------------------------------------------------------
diff --git a/test/activetasks.js b/test/activetasks.js
index 3cdd348..b2b85f3 100644
--- a/test/activetasks.js
+++ b/test/activetasks.js
@@ -1,45 +1,37 @@
 import assert from 'assert';
 import nock from 'nock';
-import Lab from 'lab';
-export const lab = Lab.script();
 import { createConfigFile } from './common';
 
 import nmo from '../src/nmo.js';
 import getActiveTask, { filterTasks, cli }  from '../src/activetasks.js';
+import { consoleMock } from './helpers';
 
-lab.experiment('activetasks', () => {
+describe('activetasks', () => {
   createConfigFile();
-  lab.beforeEach((done) => {
-    nmo
-      .load({nmoconf: __dirname + '/fixtures/randomini'})
-      .then(() => done())
-      .catch(() => done());
-  });
 
-  lab.experiment('cli', () => {
-    const oldConsole = console.log;
+  beforeEach(() => {
+    return nmo
+      .load({nmoconf: __dirname + '/fixtures/randomini'});
+  });
 
-    lab.afterEach(done => {
-      console.log = oldConsole;
-      done();
-    });
+  describe('cli', () => {
 
-    lab.test('no arguments', done => {
+    it('no arguments', done => {
       cli().catch(err => {
         assert.ok(/Usage/.test(err.message));
         done();
       });
     });
 
-    lab.test('does json', done => {
+    it('does json', done => {
       nock('http://127.0.0.11')
         .get('/_active_tasks')
         .reply(200, []);
 
-      console.log = msg => {
-        assert.deepEqual(msg, []);
+      console.log = consoleMock(msg => {
         done();
-      };
+        assert.deepEqual(msg, []);
+      });
 
       nmo
         .load({nmoconf: __dirname + '/fixtures/randomini', json: true})
@@ -49,27 +41,27 @@ lab.experiment('activetasks', () => {
 
     });
 
-    lab.test('rejests errors', done => {
-      cli('http://127.0.0.11')
+    it('rejests errors', () => {
+      return cli('http://127.0.0.11')
       .catch(err => {
         assert.ok(err);
-        done();
       });
     });
 
-    lab.test('Not existing cluster', (done) => {
+    it('Not existing cluster', () => {
 
-      cli('wrong').catch(err => {
+      return cli('wrong').catch(err => {
         assert.ok(/Cluster does not exist/.test(err.message));
-        done();
       });
     });
 
-    lab.test('returns no active tasks for filter', done => {
-      console.log = function (msg) {
+
+
+    it('returns no active tasks for filter', done => {
+      console.log = consoleMock((msg, log) => {
         assert.ok(/for that filter/.test(msg));
         done();
-      };
+      });
 
       nock('http://127.0.0.11')
         .get('/_active_tasks')
@@ -79,11 +71,11 @@ lab.experiment('activetasks', () => {
     });
 
 
-    lab.test('returns no active tasks', done => {
-      console.log = function (msg) {
+    it('returns no active tasks', done => {
+      console.log = consoleMock(function (msg) {
         assert.ok(/There are no active tasks/.test(msg));
         done();
-      };
+      });
 
       nock('http://127.0.0.11')
         .get('/_active_tasks')
@@ -92,7 +84,7 @@ lab.experiment('activetasks', () => {
       cli('http://127.0.0.11');
     });
 
-    lab.test('returns active tasks', done => {
+    it('returns active tasks', done => {
       const resp = `[{"node":"node1@127.0.0.1","pid":"<0.8331.5>",
                     "changes_pending":null,"checkpoint_interval":5000,
                     "checkpointed_source_seq":"1234",
@@ -112,12 +104,12 @@ lab.experiment('activetasks', () => {
         .get('/_active_tasks')
         .reply(200, resp);
 
-      console.log = msg => {
+      console.log = consoleMock(msg => {
         if (!/Active/.test(msg)) { return; }
 
         assert.ok(/Active Tasks:/.test(msg));
         done();
-      };
+      });
 
       cli('http://127.0.0.11');
     });
@@ -126,29 +118,26 @@ lab.experiment('activetasks', () => {
 
 
 
-  lab.experiment('getActiveTask', () => {
+  describe('getActiveTask', () => {
 
-    lab.test('rejects for invalid url', done => {
+    it('rejects for invalid url', () => {
 
-      getActiveTask('hhhh')
+      return getActiveTask('hhhh')
         .catch(err => {
           assert.deepEqual(err.type, 'EUSAGE');
-          done();
         });
     });
 
-    lab.test('returns error for bad connections', done => {
+    it('returns error for bad connections', () => {
 
-      getActiveTask('http://127.1.1.10')
+      return getActiveTask('http://127.1.1.10')
       .catch(err => {
-        console.log('ERR', err);
         assert.ok(/Could not connect/.test(err.message));
-        done();
       });
 
     });
 
-    lab.test('returns active tasks info', done => {
+    it('returns active tasks info', () => {
       const resp = `[{"node":"node1@127.0.0.1","pid":"<0.8331.5>",
                     "changes_pending":null,"checkpoint_interval":5000,
                     "checkpointed_source_seq":"1234",
@@ -168,15 +157,14 @@ lab.experiment('activetasks', () => {
         .get('/_active_tasks')
         .reply(200, resp);
 
-      getActiveTask('http://127.0.0.11')
+      return getActiveTask('http://127.0.0.11')
       .then(activetasks => {
         assert.deepEqual(activetasks, JSON.parse(resp));
-        done();
       });
     });
   });
 
-  lab.experiment('filterTasks', () => {
+  describe('filterTasks', () => {
     const tasks = [
       {
         type: 'replication',
@@ -192,24 +180,21 @@ lab.experiment('activetasks', () => {
       },
     ];
 
-    lab.test('for no filter returns', done => {
+    it('for no filter returns', () => {
       const filtered = filterTasks(tasks);
       assert.deepEqual(tasks, filtered);
-      done();
     });
 
-    lab.test('only returns for filtered type', done => {
+    it('only returns for filtered type', () => {
       const filtered = filterTasks(tasks, 'replication');
       assert.deepEqual(filtered.length, 1);
       assert.deepEqual(filtered[0].type, 'replication');
-      done();
     });
 
-    lab.test('returns filter for database', done => {
+    it('returns filter for database', () => {
       const filtered = filterTasks(tasks, 'mydatabase');
       assert.deepEqual(filtered.length, 2);
       assert.deepEqual(filtered[0].target, 'mydatabase');
-      done();
     });
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/cluster.js
----------------------------------------------------------------------
diff --git a/test/cluster.js b/test/cluster.js
index adc741f..b88809d 100644
--- a/test/cluster.js
+++ b/test/cluster.js
@@ -1,67 +1,55 @@
 import assert from 'assert';
 import nock from 'nock';
 
-import Lab from 'lab';
-export const lab = Lab.script();
-
 import * as cluster from '../src/cluster.js';
 import nmo from '../src/nmo.js';
 import {createConfigFile} from './common.js';
-
-
+import { consoleMock } from './helpers';
 
 const nmoconf = {nmoconf: __dirname + '/fixtures/randomini'};
-const oldConsole = console.log;
 
-lab.experiment('cluster - get', () => {
+describe('cluster - get', () => {
 
-  lab.beforeEach((done) => {
+  beforeEach(() => {
     createConfigFile();
-    nmo
+    return nmo
       .load(nmoconf)
-      .then(() => done())
-      .catch(() => done());
   });
 
-  lab.test('errors on nmoconf', (done) => {
-    cluster
+  it('errors on nmoconf', () => {
+    return cluster
       .get('nmoconfig')
       .catch((err) => {
         assert.ok(/valid/.test(err.message));
-        done();
       });
   });
 
-  lab.test('returns the clustername', (done) => {
-    cluster
+  it('returns the clustername', () => {
+    return cluster
       .get('clusterone', 'node0')
       .then((res) => {
         assert.equal(res, 'http://127.0.0.1');
-        done();
       });
     });
 });
 
-lab.experiment('cluster - add', () => {
+describe('cluster - add', () => {
 
-  lab.beforeEach((done) => {
+  beforeEach(() => {
     createConfigFile();
-    nmo
-      .load(nmoconf)
-      .then(() => done())
-      .catch(() => done());
+    return nmo
+      .load(nmoconf);
   });
 
-  lab.test('errors on empty args', (done) => {
-    cluster
+  it('errors on empty args', () => {
+    return cluster
       .add()
       .catch((err) => {
         assert.ok(/provide/.test(err.message));
-        done();
       });
   });
 
-  lab.test('errors on nmoconf', (done) => {
+  it('errors on nmoconf', (done) => {
     cluster
       .add('foo', 'bar', 'nmoconfig')
       .catch((err) => {
@@ -70,7 +58,7 @@ lab.experiment('cluster - add', () => {
       });
   });
 
-  lab.test('adds cluster', (done) => {
+  it('adds cluster', (done) => {
     cluster
       .add('rockbert', 'artischockbert', 'foocluster')
       .then((res) => {
@@ -85,54 +73,47 @@ lab.experiment('cluster - add', () => {
 
 });
 
-lab.experiment('cluster - join', () => {
+describe('cluster - join', () => {
 
-  lab.beforeEach((done) => {
+  beforeEach(() => {
     createConfigFile();
-    nmo
-      .load(nmoconf)
-      .then(() => done())
-      .catch(() => done());
-
+    return nmo
+      .load(nmoconf);
   });
 
-  lab.test('errors on empty args', (done) => {
-    cluster
+  it('errors on empty args', () => {
+    return cluster
       .join()
       .catch((err) => {
         assert.ok(/Usage/.test(err.message));
-        done();
       });
   });
 
-  lab.test('errors on nmoconf', (done) => {
-    cluster
+  it('errors on nmoconf', () => {
+    return cluster
       .join('nmoconfig')
       .catch((err) => {
         assert.ok(/valid/.test(err.message));
-        done();
       });
   });
 
-  lab.test('errors on a cluster with no nodes', (done) => {
-    cluster
+  it('errors on a cluster with no nodes', () => {
+    return cluster
       .join('doesnotexist')
       .catch((err) => {
         assert.ok(/any nodes/.test(err.message));
-        done();
       });
   });
 
-  lab.test('errors on cluster with 1 node', (done) => {
-    cluster
+  it('errors on cluster with 1 node', () => {
+    return cluster
       .join('onenodecluster')
       .catch((err) => {
         assert.ok(/enough nodes/.test(err.message));
-        done();
       });
   });
 
-  lab.test('warns on offline nodes', (done) => {
+  it('warns on offline nodes', () => {
     nock('http://neverexists.neverexists')
       .get('/')
       .reply(500);
@@ -141,15 +122,14 @@ lab.experiment('cluster - join', () => {
       .get('/')
       .reply(500);
 
-    cluster
+    return cluster
       .join('clustervalidurlsbothdown')
       .catch((err) => {
         assert.ok(/nodes are/.test(err.message));
-        done();
       });
   });
 
-  lab.test('warns on offline node', (done) => {
+  it('warns on offline node', () => {
     nock('http://neverexists.neverexists')
       .get('/')
       .reply(500);
@@ -158,15 +138,14 @@ lab.experiment('cluster - join', () => {
       .get('/')
       .reply(200);
 
-    cluster
+    return cluster
       .join('clustervalidurlsonedown')
       .catch((err) => {
         assert.ok(/node is/.test(err.message));
-        done();
       });
   });
 
-  lab.test('succeeds at online nodes with pw', (done) => {
+  it('succeeds at online nodes with pw', () => {
     nock('http://a:b@127.0.0.1:1337')
       .get('/')
       .reply(200);
@@ -199,15 +178,14 @@ lab.experiment('cluster - join', () => {
       .post('/_cluster_setup')
       .reply(200, {ok: true});
 
-    cluster
+    return cluster
       .join('clustervalidurlswithpw')
       .then((res) => {
         assert.deepEqual(res, { ok: true });
-        done();
       });
   });
 
-  lab.test('succeeds at online nodes', (done) => {
+  it('succeeds at online nodes', () => {
     nock('http://127.0.0.1:1337')
       .get('/')
       .reply(200);
@@ -240,15 +218,14 @@ lab.experiment('cluster - join', () => {
       .post('/_cluster_setup')
       .reply(200, {ok: true});
 
-    cluster
+    return cluster
       .join('clustervalidurls')
       .then((res) => {
         assert.deepEqual(res, { ok: true });
-        done();
       });
   });
 
-  lab.test('succeeds with offline nodes, but --force given', (done) => {
+  it('succeeds with offline nodes, but --force given', () => {
     nock('http://127.0.0.1:1337')
       .get('/')
       .reply(200);
@@ -269,67 +246,56 @@ lab.experiment('cluster - join', () => {
       .get('/')
       .reply(500);
 
-    nmo.load({nmoconf: __dirname + '/fixtures/randomini', force: true}).then(() => {
-      cluster
+    return nmo.load({nmoconf: __dirname + '/fixtures/randomini', force: true}).then(() => {
+      return cluster
         .join('clustervalidurlsonedown')
         .then((res) => {
           assert.deepEqual(res, { ok: true });
-          done();
         });
     });
   });
-
 });
 
 
-lab.experiment('cluster - cli', () => {
+describe('cluster - cli', () => {
 
-  lab.beforeEach((done) => {
+  beforeEach(() => {
     createConfigFile();
-    nmo
+    return nmo
       .load(nmoconf)
-      .then(() => done())
-      .catch(() => done());
-
   });
 
-  lab.afterEach((done) => {
-    console.log = oldConsole;
-    done();
-  });
-
-  lab.test('adds cluster', (done) => {
-    cluster
+  it('adds cluster', () => {
+    return cluster
       .cli('add', 'rockbert', 'artischockbert', 'foocluster2')
       .then((res) => {
-        cluster
+        return cluster
           .get('foocluster2')
           .then((res) => {
             assert.deepEqual(res, {rockbert: 'artischockbert'});
-            done();
           });
       });
   });
 
-  lab.test('gets cluster', (done) => {
-    console.log = (...args) => {
+  it('gets cluster', (done) => {
+    console.log = consoleMock((...args) => {
       if (/rockbert=artischockbert/.test(args[0])) {
         assert.equal('rockbert=artischockbert\n', args[0]);
         done();
       }
-    };
+    });
 
-    nmo.load({nmoconf: __dirname + '/fixtures/randomini' }).then(() => {
-      cluster
+    return nmo.load({nmoconf: __dirname + '/fixtures/randomini' }).then(() => {
+      return cluster
         .cli('add', 'rockbert', 'artischockbert', 'foocluster3')
         .then((res) => {
-          cluster
+          return cluster
             .cli('get', 'foocluster3');
           });
         });
   });
 
-  lab.test('joins cluster', (done) => {
+  it('joins cluster', () => {
     nock('http://127.0.0.1:1337')
       .get('/')
       .reply(200);
@@ -362,16 +328,15 @@ lab.experiment('cluster - cli', () => {
       .post('/_cluster_setup')
       .reply(200, {ok: true});
 
-    console.log = (...args) => {
+    console.log = consoleMock((...args) => {
       assert.equal('cluster joined', args[0]);
-      done();
-    };
+    });
 
-    cluster
+    return cluster
       .cli('join', 'clustervalidurls');
   });
 
-  lab.test('returns error on wrong usage', (done) => {
+  it('returns error on wrong usage', (done) => {
     try {
       cluster.cli('lalala');
     } catch(err) {

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/config.js
----------------------------------------------------------------------
diff --git a/test/config.js b/test/config.js
index 329ece5..2b7f9fa 100644
--- a/test/config.js
+++ b/test/config.js
@@ -1,12 +1,10 @@
 import assert from 'assert';
 
-import Lab from 'lab';
-export const lab = Lab.script();
-
 import * as config from '../src/config.js';
 
 import ini from 'ini';
 import fs from 'fs';
+import { consoleMock } from './helpers';
 
 const data = `[clusterone]
 node0=http://127.0.0.1
@@ -38,270 +36,232 @@ j=janjuleschlie
 mussman=dermussmaen
 `;
 
-const oldConsole = console.log;
-
-lab.experiment('config', () => {
+describe('config', () => {
 
-  lab.experiment('load', () => {
+  describe('load', () => {
 
-    lab.beforeEach((done) => {
+    beforeEach((done) => {
       fs.writeFileSync(__dirname + '/fixtures/randomini', data, 'utf-8');
       done();
     });
 
-    lab.test('loads a defined config', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('loads a defined config', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
           assert.equal(res.get('gang').rocko, 'artischocko');
-          done();
         });
     });
   });
 
-  lab.experiment('set', () => {
+  describe('set', () => {
 
-    lab.beforeEach((done) => {
+    beforeEach((done) => {
       fs.writeFileSync(__dirname + '/fixtures/randomini', data, 'utf-8');
       done();
     });
 
-    lab.test('saves a value', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('saves a value', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.set('cluster1337', 'node1337', '192.168.133.7').then((e) => {
-            const c = ini.parse(fs.readFileSync(__dirname + '/fixtures/randomini', 'utf-8'));
-            assert.equal(c.clusterone.node1, 'http://192.168.0.1');
-            assert.equal(c.gang.rocko, 'artischocko');
-            assert.equal(c.cluster1337.node1337, '192.168.133.7');
-            done();
-          });
+          return config.set('cluster1337', 'node1337', '192.168.133.7')
+        })
+        .then((e) => {
+          const c = ini.parse(fs.readFileSync(__dirname + '/fixtures/randomini', 'utf-8'));
+          assert.equal(c.clusterone.node1, 'http://192.168.0.1');
+          assert.equal(c.gang.rocko, 'artischocko');
+          assert.equal(c.cluster1337.node1337, '192.168.133.7');
         });
     });
 
-    lab.test('errors if not all values provided', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('errors if not all values provided', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
           config.set().catch((err) => {
             assert.ok(err instanceof Error);
-            done();
           });
         });
     });
 
-    lab.test('errors if not all values provided', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('errors if not all values provided', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
           config.set('foo').catch((err) => {
             assert.ok(err instanceof Error);
-            done();
           });
         });
     });
 
-    lab.test('errors if not all values provided', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('errors if not all values provided', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
           config.set('foo', 'bar').catch((err) => {
             assert.ok(err instanceof Error);
-            done();
           });
         });
     });
 
-    lab.test('saves can overwrite old values', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('saves can overwrite old values', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.set('clusterone', 'node1', '192.168.133.7').then((e) => {
-            const c = ini.parse(fs.readFileSync(__dirname + '/fixtures/randomini', 'utf-8'));
-            assert.equal(c.clusterone.node1, '192.168.133.7');
-            done();
-          });
+          return config.set('clusterone', 'node1', '192.168.133.7')
+        })
+        .then((e) => {
+          const c = ini.parse(fs.readFileSync(__dirname + '/fixtures/randomini', 'utf-8'));
+          assert.equal(c.clusterone.node1, '192.168.133.7');
         });
     });
   });
 
-  lab.experiment('get', () => {
+  describe('get', () => {
 
-    lab.beforeEach((done) => {
+    beforeEach((done) => {
       fs.writeFileSync(__dirname + '/fixtures/randomini', data, 'utf-8');
       done();
     });
 
-    lab.test('returns the whole config as JSON', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('returns the whole config as JSON', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
           const result = config.get();
           assert.deepEqual(jsonData, result);
-          done();
         });
     });
 
-    lab.test('will get sections as JSON', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
-        .then((res) => {
+    it('will get sections as JSON', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
+        .then(res => {
           const result = config.get('gang');
           assert.deepEqual(jsonData.gang, result);
-          done();
         });
     });
 
-    lab.test('will get keys', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('will get keys', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
           const result = config.get('gang', 'rocko');
           assert.equal(jsonData.gang.rocko, result);
-          done();
         });
     });
   });
 
-  lab.experiment('cli', () => {
+  describe('cli', () => {
 
-    lab.beforeEach((done) => {
+    beforeEach((done) => {
       fs.writeFileSync(__dirname + '/fixtures/randomini', data, 'utf-8');
       done();
     });
 
-    lab.afterEach((done) => {
-      console.log = oldConsole;
-      done();
-    });
-
-   lab.test('it can get the whole config', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+   it('it can get the whole config', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.cli().then((result) => {
+          return config.cli().then((result) => {
             assert.deepEqual(jsonData, result);
-            done();
           });
         });
     });
 
-    lab.test('will print the whole config as ini', (done) => {
+    it('will print the whole config as ini', (done) => {
 
-      console.log = (...args) => {
+      console.log = consoleMock((...args) => {
         assert.equal(data, args[0]);
-      };
+        done();
+      });
 
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.cli('get').then((result) => {
-            done();
-          });
+          return config.cli('get')
         });
     });
 
-    lab.test('will print the whole config as JSON, if json = true', (done) => {
+    it('will print the whole config as JSON, if json = true', (done) => {
 
-      console.log = (...args) => {
+      console.log = consoleMock((...args) => {
         assert.deepEqual(jsonData, args[0]);
         done();
-      };
+      });
 
-      config.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
+      return config.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
         .then((res) => {
-          config.cli('get');
+          return config.cli('get');
         });
     });
 
-    lab.test('it can handle sections in the config', (done) => {
+    it('it can handle sections in the config', () => {
 
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.cli('get', 'gang').then((result) => {
+          return config.cli('get', 'gang').then((result) => {
             assert.deepEqual(jsonData.gang, result);
-            done();
           });
         });
     });
 
-    lab.test('will print the gang config as ini', (done) => {
+    it('will print the gang config as ini', (done) => {
 
-      console.log = (...args) => {
+      console.log = consoleMock((...args) => {
         assert.equal(gangConf, args[0]);
-      };
+        done();
+      });
 
       config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.cli('get', 'gang').then((result) => {
-            done();
-          });
+          config.cli('get', 'gang');
         });
     });
 
-    lab.test('it can handle sections with keys in the config', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
+    it('it can handle sections with keys in the config', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
         .then((res) => {
-          config.cli('get', 'gang', 'rocko').then((result) => {
-            assert.deepEqual({rocko: 'artischocko'}, result);
-            done();
-          });
+          return config.cli('get', 'gang', 'rocko');
+        })
+        .then((result) => {
+          assert.deepEqual({rocko: 'artischocko'}, result);
         });
     });
 
-    lab.test('will print the gang member', (done) => {
+    it('will print the gang member', () => {
 
-      console.log = (...args) => {
-        assert.equal('artischocko', args[0]);
-      };
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.cli('get', 'gang', 'rocko').then((result) => {
-            done();
-          });
+          return config.cli('get', 'gang', 'rocko');
+        })
+        .then(res => {
+          assert.equal('artischocko', res);
         });
     });
 
-    lab.test('will print the gang member as JSON, if json = true', (done) => {
+    it('will print the gang member as JSON, if json = true', () => {
 
-      console.log = (...args) => {
-        assert.deepEqual({rocko: 'artischocko'}, args[0]);
-      };
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
+      return config.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
         .then((res) => {
-          config.cli('get', 'gang', 'rocko').then((result) => {
-            done();
-          });
+          return config.cli('get', 'gang', 'rocko');
+        })
+        .then(res => {
+          console.log('res', res);
+          assert.deepEqual({rocko: 'artischocko'}, res);
         });
     });
 
-    lab.test('saves a value', (done) => {
-
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('saves a value', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then((res) => {
-          config.cli('set', 'cluster1337', 'node1337', '192.168.133.7').then((e) => {
-            const c = ini.parse(fs.readFileSync(__dirname + '/fixtures/randomini', 'utf-8'));
-            assert.equal(c.clusterone.node1, 'http://192.168.0.1');
-            assert.equal(c.gang.rocko, 'artischocko');
-            assert.equal(c.cluster1337.node1337, '192.168.133.7');
-            done();
-          });
+          return config.cli('set', 'cluster1337', 'node1337', '192.168.133.7');
+        })
+        .then((e) => {
+          const c = ini.parse(fs.readFileSync(__dirname + '/fixtures/randomini', 'utf-8'));
+          assert.equal(c.clusterone.node1, 'http://192.168.0.1');
+          assert.equal(c.gang.rocko, 'artischocko');
+          assert.equal(c.cluster1337.node1337, '192.168.133.7');
         });
     });
 
-    lab.test('returns error on wrong usage', (done) => {
-      config.load({nmoconf: __dirname + '/fixtures/randomini'})
+    it('returns error on wrong usage', () => {
+      return config.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then(() => {
-
-          config
+          return config
             .cli('lalala');
-
         }).catch((err) => {
           assert.ok(err instanceof Error);
-          done();
         });
     });
   });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/couch-config.js
----------------------------------------------------------------------
diff --git a/test/couch-config.js b/test/couch-config.js
index 5969e99..a57f7cb 100644
--- a/test/couch-config.js
+++ b/test/couch-config.js
@@ -1,112 +1,99 @@
 import assert from 'assert';
 
-import Lab from 'lab';
-export const lab = Lab.script();
 import nock from 'nock';
 import { createConfigFile } from './common';
 import nmo from '../src/nmo.js';
 import {cli, setConfig, getClusterNodes, buildConfigUrl, getConfig, get, set} from '../src/couch-config.js';
+import { consoleMock } from './helpers';
 
-lab.experiment('couch-config', () => {
+describe('couch-config', () => {
   createConfigFile();
 
-  lab.beforeEach((done) => {
-    nmo
-      .load({nmoconf: __dirname + '/fixtures/randomini'})
-      .then(() => done())
-      .catch(() => done());
+  beforeEach(() => {
+    return nmo
+      .load({nmoconf: __dirname + '/fixtures/randomini'});
   });
 
-  lab.experiment('cli', () => {
-
-    lab.test('no arguments', (done) => {
-
-      cli().catch(err => {
-        assert.ok(/Usage/.test(err.message));
-        done();
-      });
+  describe('cli', () => {
 
+    it('no arguments', () => {
+      return cli()
+        .catch(err => {
+          assert.ok(/Usage/.test(err.message));
+        });
     });
 
-    lab.test('non-existing command', (done) => {
+    it('non-existing command', () => {
 
-      cli('wrong', 'command').catch(err => {
-        assert.ok(/Usage/.test(err.message));
-        done();
-      });
+      return cli('wrong', 'command')
+        .catch(err => {
+          assert.ok(/Usage/.test(err.message));
+        });
 
     });
 
-    lab.test('error on missing cluster', (done) => {
+    it('error on missing cluster', () => {
 
-      cli('get').catch(err => {
+      return cli('get')
+        .catch(err => {
         assert.ok(/Usage/.test(err.message));
-        done();
-      });
+        });
 
     });
 
-    lab.test('error on non-existing cluster', (done) => {
-
-      cli('get', 'not-exist').catch(err => {
-        assert.ok(/Cluster/.test(err.message));
-        done();
-      });
+    it('error on non-existing cluster', () => {
 
+      return cli('get', 'not-exist')
+        .catch(err => {
+          assert.ok(/Cluster/.test(err.message));
+        });
     });
 
   });
 
-  lab.experiment('api', () => {
+  describe('api', () => {
 
-    lab.test('getClusterNodes returns existing nodes', (done) => {
+    it('getClusterNodes returns existing nodes', () => {
       const nodes = getClusterNodes('clusterone');
 
       assert.deepEqual(nodes, {
         node0: 'http://127.0.0.1',
         node1: 'http://192.168.0.1'
       });
-
-      done();
     });
 
-    lab.test('buildConfigUrl builds correctly with node and url', (done) => {
+    it('buildConfigUrl builds correctly with node and url', () => {
       const url = buildConfigUrl('node', 'http://127.0.0.1');
       assert.deepEqual(url, 'http://127.0.0.1/_node/node/_config');
-      done();
     });
 
-    lab.test('buildConfigUrl builds correctly with node, url and section', (done) => {
+    it('buildConfigUrl builds correctly with node, url and section', () => {
       const url = buildConfigUrl('node', 'http://127.0.0.1', 'a-section');
       assert.deepEqual(url, 'http://127.0.0.1/_node/node/_config/a-section');
-      done();
     });
 
-    lab.test('getConfig throws error on bad url', (done) => {
-      getConfig('node1', 'bad-url')
+    it('getConfig throws error on bad url', () => {
+      return getConfig('node1', 'bad-url')
       .catch(err => {
         assert.ok(/not a valid url/.test(err.message));
-        done();
       });
     });
 
-    lab.test('getConfig throws error on invalid protocol', (done) => {
-      getConfig('node1', 'ftp://bad-url')
-      .catch(err => {
-        assert.ok(/invalid protocol/.test(err.message));
-        done();
-      });
+    it('getConfig throws error on invalid protocol', () => {
+      return getConfig('node1', 'ftp://bad-url')
+        .catch(err => {
+          assert.ok(/invalid protocol/.test(err.message));
+        });
     });
 
-    lab.test('gets config bad url returns false', (done) => {
-      getConfig('node1', 'http://127.0.0.2/')
-      .catch(err => {
-        assert.ok(/Could not find node/.test(err.message));
-        done();
-      });
+    it('gets config bad url returns false', () => {
+      return getConfig('node1', 'http://127.0.0.2/')
+        .catch(err => {
+          assert.ok(/Could not find node/.test(err.message));
+        });
     });
 
-    lab.test('gets config for node', (done) => {
+    it('gets config for node', () => {
       const resp = {
         config1: 'hello',
         config2: 'boom'
@@ -116,27 +103,19 @@ lab.experiment('couch-config', () => {
         .get('/_node/node1/_config/uuid')
         .reply(200, resp);
 
-      getConfig('node1', 'http://127.0.0.1/_node/node1/_config/uuid')
-      .then(config => {
-        assert.deepEqual(config, {
-          node: 'node1',
-          config: resp
+      return getConfig('node1', 'http://127.0.0.1/_node/node1/_config/uuid')
+        .then(config => {
+          assert.deepEqual(config, {
+            node: 'node1',
+            config: resp
+          });
         });
-        done();
-      });
     });
 
   });
 
-  lab.experiment('get cmd', () => {
-    let oldConsole = console.log;
-
-    lab.afterEach(done => {
-      console.log = oldConsole;
-      done();
-    });
-
-    lab.test('get returns config', (done) => {
+  describe('get cmd', () => {
+    it('get returns config', () => {
       const nodes = {
         node1: 'http://127.0.0.1'
       };
@@ -150,19 +129,18 @@ lab.experiment('couch-config', () => {
         .get('/_node/node1/_config/uuid')
         .reply(200, resp);
 
-      get('cluster', nodes, 'uuid')
-      .then(config => {
-        assert.deepEqual(config, {
-          node1: {
-          config1: 'hello',
-          config2: 'boom'
-        }
-       });
-       done();
+      return get('cluster', nodes, 'uuid')
+        .then(config => {
+          assert.deepEqual(config, {
+            node1: {
+            config1: 'hello',
+            config2: 'boom'
+          }
+         });
       });
     });
 
-    lab.test('get returns json if set', done => {
+    it('get returns json if set', () => {
       const nodes = {
         node1: 'http://127.0.0.100'
       };
@@ -176,19 +154,17 @@ lab.experiment('couch-config', () => {
         .get('/_node/node1/_config/uuid')
         .reply(200, resp);
 
-      nmo
+      return nmo
         .load({nmoconf: __dirname + '/fixtures/randomini', json: true})
         .then(() => {
-
-          get('cluster', nodes, 'uuid')
-          .then(jsonresp => {
-            assert.deepEqual({node1: resp}, jsonresp);
-            done();
-          });
+          return get('cluster', nodes, 'uuid');
+        })
+        .then(jsonresp => {
+          assert.deepEqual({node1: resp}, jsonresp);
         });
     });
 
-    lab.test('get prints config', done => {
+    it('get prints config', (done) => {
       const nodes = {
         node1: 'http://127.0.0.1'
       };
@@ -202,24 +178,20 @@ lab.experiment('couch-config', () => {
         .get('/_node/node1/_config/uuid')
         .reply(200, resp);
 
-      console.log = (msg) => {
-        if (/NODE:/.test(msg)) {
-          return;
-        }
-
+      console.log = consoleMock(msg => {
         assert.ok(/config1/.test(msg));
         assert.ok(/config2/.test(msg));
 
         done();
-      };
+      });
 
       get('cluster', nodes, 'uuid');
     });
   });
 
-  lab.experiment('set cmd', () => {
+  describe('set cmd', () => {
 
-    lab.test('returns error if all nodes are not online', done => {
+    it('returns error if all nodes are not online', () => {
       nock('http://127.0.0.1')
       .get('/')
       .reply(500);
@@ -228,16 +200,13 @@ lab.experiment('couch-config', () => {
       .get('/')
       .reply(500);
 
-      set('clusterone', 'nodes', 'section', 'key', 'value')
-      .catch(err => {
-        console.log('ERR', err);
-        assert.ok(/is offline/.test(err.message));
-        done();
-      });
-
+      return set('clusterone', 'nodes', 'section', 'key', 'value')
+        .catch(err => {
+          assert.ok(/is offline/.test(err.message));
+        });
     });
 
-    lab.test('sets config on all nodes for cluster', done => {
+    it('sets config on all nodes for cluster', () => {
       //isonline
       nock('http://127.0.0.1')
       .get('/')
@@ -256,17 +225,15 @@ lab.experiment('couch-config', () => {
       .put('/_node/node1/_config/section/key', JSON.stringify('value'))
       .reply(200, JSON.stringify('oldvalue'));
 
-      set('clusterone', getClusterNodes('clusterone'), 'section', 'key', 'value')
+      return set('clusterone', getClusterNodes('clusterone'), 'section', 'key', 'value')
       .then(resp => {
-        assert.deepEqual(resp, [
-          { node: 'node0', oldvalue: 'oldvalue', newvalue: 'value' },
-          { node: 'node1', oldvalue: 'oldvalue', newvalue: 'value' } ]);
-        done();
-      });
-
+          assert.deepEqual(resp, [
+            { node: 'node0', oldvalue: 'oldvalue', newvalue: 'value' },
+            { node: 'node1', oldvalue: 'oldvalue', newvalue: 'value' } ]);
+        });
     });
 
-    lab.test('sets config throws error', done => {
+    it('sets config throws error', () => {
       //isonline
       nock('http://127.0.0.1')
       .get('/')
@@ -281,20 +248,18 @@ lab.experiment('couch-config', () => {
       .put('/_node/node0/_config/section/key', JSON.stringify('value'))
       .reply(200, JSON.stringify('oldvalue'));
 
-      set('clusterone', getClusterNodes('clusterone'), 'section', 'key', 'value')
+      return set('clusterone', getClusterNodes('clusterone'), 'section', 'key', 'value')
       .catch(err => {
         assert.ok(/Error on set config for node/.test(err.message));
-        done();
       });
 
     });
 
-    lab.test('setsConfig warns on incorrect url', done => {
+    it('setsConfig warns on incorrect url', () => {
 
-      setConfig('node1', 'ftp://127.0.0.1', 'section', 'key', 'value')
+      return setConfig('node1', 'ftp://127.0.0.1', 'section', 'key', 'value')
       .catch(err => {
         assert.ok(/invalid protocol/.test(err.message));
-        done();
       });
 
     });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/help.js
----------------------------------------------------------------------
diff --git a/test/help.js b/test/help.js
index 81e2180..13418be 100644
--- a/test/help.js
+++ b/test/help.js
@@ -1,43 +1,32 @@
 import assert from 'assert';
 
-import Lab from 'lab';
-export const lab = Lab.script();
-
 import { createConfigFile } from './common';
 import help from '../src/help.js';
 import {cli} from '../src/help.js';
 
-import {load} from '../src/nmo.js';
+import nmo from '../src/nmo.js';
+import { consoleMock } from './helpers';
 
 const oldConsole = console.log;
 
-lab.experiment('help', () => {
+describe('help', () => {
   createConfigFile();
 
-  lab.before((done) => {
-    load({nmoconf: __dirname + '/fixtures/randomini'}).then(() => {
-      done();
-    });
-  });
-
-  lab.afterEach((done) => {
-    console.log = oldConsole;
-    done();
+  beforeEach(() => {
+    return nmo.load({nmoconf: __dirname + '/fixtures/randomini'});
   });
 
-  lab.test('prints available commands', (done) => {
-    console.log = (...args) => {
+  it('prints available commands', (done) => {
+    console.log = consoleMock((...args) => {
       assert.ok(/help/.test(args[0]));
       assert.ok(/isonline/.test(args[0]));
-    };
+      done();
+    });
 
-    help()
-      .then((res) => {
-        done();
-      });
+    help();
   });
 
-  lab.test('opens manpages', (done) => {
+  it('opens manpages', (done) => {
     cli('help')
       .then((child) => {
         child.kill();

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/helpers.js
----------------------------------------------------------------------
diff --git a/test/helpers.js b/test/helpers.js
new file mode 100644
index 0000000..5d6b3d9
--- /dev/null
+++ b/test/helpers.js
@@ -0,0 +1,17 @@
+
+const origConsole = console.log;
+export function consoleMock (fn) {
+  let count = 0;
+  return function (...args) {
+    if (count > 0) {
+      origConsole.apply(origConsole, args);
+      console.log = origConsole;
+      return;
+    }
+
+    count += 1;
+    args.push(origConsole);
+    fn.apply(fn, args);
+    console.log = origConsole;
+  };
+}

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/import-csv.js
----------------------------------------------------------------------
diff --git a/test/import-csv.js b/test/import-csv.js
index 8b9bb5b..2bbcbe1 100644
--- a/test/import-csv.js
+++ b/test/import-csv.js
@@ -1,7 +1,5 @@
 import assert from 'assert';
 
-import Lab from 'lab';
-export const lab = Lab.script();
 import nock from 'nock';
 import { createConfigFile } from './common';
 import nmo from '../src/nmo.js';
@@ -22,76 +20,69 @@ const docs = {
     }
   ]};
 
-lab.experiment('import csv', () => {
+describe('import csv', () => {
   createConfigFile();
-  lab.beforeEach((done) => {
-    nmo
-      .load({nmoconf: __dirname + '/fixtures/randomini'})
-      .then(() => done())
-      .catch(() => done());
 
-  });
+  beforeEach(() => {
+    return nmo.load({nmoconf: __dirname + '/fixtures/randomini'})
 
-  lab.experiment('cli', () => {
+  });
 
-    lab.test('throws error if no inputs', (done) => {
+  describe('cli', () => {
 
+    it('throws error if no inputs', (done) => {
       try {
         cli();
       } catch(e) {
         assert.deepEqual(e.type, 'EUSAGE');
+        done();
       }
-      done();
     });
 
-    lab.test('throws error if bad url', (done) => {
-
+    it('throws error if bad url', (done) => {
       try {
         cli('file', 'bad-url');
       } catch(e) {
         assert.ok(/not a valid url/.test(e.message));
+        done();
       }
-      done();
     });
 
-    lab.test('full integration works', (done) => {
+    it('full integration works', () => {
       nock('http://127.0.0.1:5984')
         .put('/fake-csv')
         .reply(200)
         .post('/fake-csv/_bulk_docs')
         .reply(200);
 
-      cli(__dirname + '/fixtures/fake.csv', 'http://127.0.0.1:5984/fake-csv', 'delimiter=','')
-      .then(done);
+      return cli(__dirname + '/fixtures/fake.csv', 'http://127.0.0.1:5984/fake-csv', 'delimiter=','');
     });
   });
 
-  lab.experiment('upload to couchdb', () => {
+  describe('upload to couchdb', () => {
 
-    lab.test('reports bad file', (done) => {
+    it('reports bad file', () => {
       const url = 'http://127.0.0.1:5984';
-      importcsv('bad-fake.csv', url + '/csv-upload', {}).catch(function (err) {
+      return importcsv('bad-fake.csv', url + '/csv-upload', {}).catch(function (err) {
         assert.ok(/Error reading file -/.test(err));
-        done();
       });
 
     });
 
-    lab.test('logs error for failed request', (done) => {
+    it('logs error for failed request', () => {
       const url = 'http://127.0.0.1:5984';
 
       nock(url)
         .put('/csv-upload')
         .reply(501);
 
-      importcsv(__dirname + '/fixtures/fake.csv', url + '/csv-upload', {}).catch(function (err) {
+      return importcsv(__dirname + '/fixtures/fake.csv', url + '/csv-upload', {}).catch(function (err) {
         assert.ok(/CouchDB server answered:/.test(err));
-        done();
       });
 
     });
 
-    lab.test('Uploads csv file to CouchDB', (done) => {
+    it('Uploads csv file to CouchDB', () => {
       const url = 'http://127.0.0.1:5984';
 
       nock(url)
@@ -100,14 +91,10 @@ lab.experiment('import csv', () => {
         .post('/csv-upload/_bulk_docs', docs)
         .reply(200);
 
-      importcsv(__dirname + '/fixtures/fake.csv', url + '/csv-upload', {delimiter: ',', columns: true}).then(function () {
-        done();
-      }).catch(function (err) {
+      return importcsv(__dirname + '/fixtures/fake.csv', url + '/csv-upload', {delimiter: ',', columns: true})
+      .catch(function (err) {
         throw 'error ' + err;
       });
-
     });
-
   });
-
 });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/isonline.js
----------------------------------------------------------------------
diff --git a/test/isonline.js b/test/isonline.js
index 5546789..137178b 100644
--- a/test/isonline.js
+++ b/test/isonline.js
@@ -1,45 +1,33 @@
 import assert from 'assert';
-import Lab from 'lab';
+import { consoleMock } from './helpers';
 
-import isonline from '../src/isonline.js';
-import {cli} from '../src/isonline.js';
+import isonline, {cli} from '../src/isonline.js';
 
 import * as common from './common.js';
 import nmo from '../src/nmo.js';
 
 import nock from 'nock';
 
-export let lab = Lab.script();
-const oldConsole = console.log;
 const nmoconf = {nmoconf: __dirname + '/fixtures/randomini'};
 
-common.createConfigFile();
 
-lab.experiment('isonline', () => {
+describe('isonline', () => {
+  common.createConfigFile();
 
-  lab.experiment('cli', () => {
-    lab.beforeEach((done) => {
-      nmo
-        .load(nmoconf)
-        .then(() => done())
-        .catch(() => done());
+  describe('cli', () => {
 
+    beforeEach(() => {
+      return nmo.load(nmoconf)
     });
 
-    lab.afterEach((done) => {
-      console.log = oldConsole;
-      done();
-    });
-
-    lab.test('returns error on no value provided', (done) => {
-      cli()
+    it('returns error on no value provided', () => {
+      return cli()
         .catch((err) => {
           assert.ok(err instanceof Error);
-          done();
         });
     });
 
-    lab.test('executes correct url for cluster name', (done) => {
+    it('executes correct url for cluster name', () => {
       nock('http://127.0.0.1')
         .get('/')
         .reply(200);
@@ -48,29 +36,27 @@ lab.experiment('isonline', () => {
         .get('/')
         .reply(200);
 
-      cli('clusterone')
+      return cli('clusterone')
         .then(res => {
           assert.deepEqual(res, {'http://127.0.0.1': true, 'http://192.168.0.1': true });
-          done();
         });
     });
 
-    lab.test('still executes for urls', (done) => {
+    it('still executes for urls', () => {
      nock('http://127.0.0.1')
        .get('/')
        .reply(200);
 
-     nmo
+     return nmo
        .load({nmoconf: __dirname + '/fixtures/randomini', json: true})
        .then(() => {
          return cli('http://127.0.0.1');
        }).then(res => {
          assert.deepEqual(res, {'http://127.0.0.1': true });
-         done();
        });
      });
 
-     lab.test('executes correct for multiple urls', (done) => {
+     it('executes correct for multiple urls', () => {
        nock('http://127.0.0.1')
          .get('/')
          .reply(200);
@@ -85,73 +71,56 @@ lab.experiment('isonline', () => {
            return cli('http://127.0.0.1', 'http://192.168.0.1');
          }).then(res => {
            assert.deepEqual(res, {'http://127.0.0.1': true, 'http://192.168.0.1': true });
-           done();
          });
      });
   });
 
-  lab.experiment('api', () => {
-    //I'm worried these before's are not actually running
-    lab.beforeEach((done) => {
-      nmo
-        .load(nmoconf)
-        .then(() => {
-          done();
-        })
-        .catch(() => done());
-      });
-    });
+  describe('api', () => {
 
-    lab.afterEach((done) => {
-      console.log = oldConsole;
-      done();
+    beforeEach(() => {
+      return nmo.load(nmoconf);
     });
 
-    lab.test('returns error for all other errors', (done) => {
-      isonline({})
+    it('returns error for all other errors', () => {
+      return isonline({})
         .catch((err) => {
           assert.ok(err instanceof Error);
-          done();
         });
     });
 
-    lab.test('returns false for down site', (done) => {
-      isonline('http://127.0.0.1:65516')
+    it('returns false for down site', () => {
+      return isonline('http://127.0.0.1:65516')
         .then((res) => {
           assert.deepEqual(res, {'http://127.0.0.1:65516': false});
-          done();
         });
     });
 
-    lab.test('returns an error for non http urls', (done) => {
-      isonline('ftp://127.0.0.1:65516')
+    it('returns an error for non http urls', () => {
+      return isonline('ftp://127.0.0.1:65516')
         .catch((err) => {
           assert.ok(err instanceof Error);
-          done();
         });
     });
 
-    lab.test('returns false for down site with bad DNS', (done) => {
+    it('returns false for down site with bad DNS', () => {
       isonline('http://exampleneverexists')
         .then((res) => {
           assert.deepEqual(res, {'http://exampleneverexists': false});
-          done();
         });
     });
 
-    lab.test('returns true for online site', (done) => {
+    it('returns true for online site', () => {
       nock(common.NODE)
         .get('/')
         .reply(200);
 
-      isonline(common.NODE)
+      return isonline(common.NODE)
         .then((res) => {
           assert.deepEqual(res, {[common.NODE]: true});
-          done();
         });
     });
 
-    lab.test('accepts multiple sites and options', (done) => {
+    it('accepts multiple sites and options', () => {
       nock(common.NODE)
         .get('/')
         .reply(200);
@@ -160,71 +129,63 @@ lab.experiment('isonline', () => {
         .get('/')
         .reply(200);
 
-      nmo
+      return nmo
         .load({nmoconf: __dirname + '/fixtures/randomini', json: true})
         .then(() => {
-          isonline(common.NODE, common.NODE_TWO).then((res) => {
-            assert.deepEqual(res, {
-              [common.NODE]: true,
-              [common.NODE_TWO]: true
-            });
-            done();
+          return isonline(common.NODE, common.NODE_TWO);
+        }).then((res) => {
+          assert.deepEqual(res, {
+            [common.NODE]: true,
+            [common.NODE_TWO]: true
           });
         });
     });
+  });
 
-  lab.experiment('cli', () => {
-    lab.beforeEach((done) => {
-      done();
-    });
+  describe('more cli', () => {
 
-    lab.afterEach((done) => {
-      console.log = oldConsole;
-      done();
-    });
-
-    lab.test('returns online for online nodes', (done) => {
+    it('returns online for online nodes', (done) => {
       nock(common.NODE)
         .get('/')
         .reply(200);
 
-      console.log = (...args) => {
+      console.log = consoleMock((...args) => {
         assert.ok(/online/.test(args[1]), 'returns online for online nodes');
         done();
-      };
+      });
+
       nmo.load({nmoconf: __dirname + '/fixtures/randomini', json: false})
         .then(() => {
           cli(common.NODE);
-        });
+      });
     });
 
-    lab.test('returns offline for offline nodes', (done) => {
-      console.log = (...args) => {
+    it('returns offline for offline nodes', (done) => {
+      console.log = consoleMock((...args) => {
         assert.ok(/offline/.test(args[1]), 'returns offline for online nodes');
         done();
-      };
+      });
+
       nmo.load({nmoconf: __dirname + '/fixtures/randomini'})
         .then(() => {
           cli('http://exampleneverexists');
         });
     });
 
-    lab.test('can output json', (done) => {
+    it('can output json', (done) => {
       nock(common.NODE)
         .get('/')
         .reply(200);
 
-      console.log = (...args) => {
+      console.log = consoleMock((...args) => {
         assert.deepEqual({ [common.NODE]: true }, args[0]);
-      };
+        done();
+      });
 
       nmo.load({nmoconf: __dirname + '/fixtures/randomini', json: true})
         .then(() => {
-          cli(common.NODE)
-            .then(() => {
-              done();
-            });
-        });
+          cli(common.NODE);
+      });
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/nemo.js
----------------------------------------------------------------------
diff --git a/test/nemo.js b/test/nemo.js
index fe22b17..dca7a93 100644
--- a/test/nemo.js
+++ b/test/nemo.js
@@ -1,13 +1,9 @@
 import assert from 'assert';
-
-import Lab from 'lab';
-export const lab = Lab.script();
-
 import nmo from '../src/nmo.js';
 
 
-lab.experiment('nmo', () => {
-  lab.test('throws for api commands if config not loaded', (done) => {
+describe('nmo', () => {
+  it('throws for api commands if config not loaded', (done) => {
     nmo.config = null;
     assert.throws(
       function () {
@@ -18,7 +14,7 @@ lab.experiment('nmo', () => {
     done();
   });
 
-  lab.test('throws for cli commands if config not loaded', (done) => {
+  it('throws for cli commands if config not loaded', (done) => {
     nmo.config = null;
     assert.throws(
       function () {
@@ -29,7 +25,7 @@ lab.experiment('nmo', () => {
     done();
   });
 
-  lab.test('does not throw for cli commands if config not loaded', (done) => {
+  it('does not throw for cli commands if config not loaded', (done) => {
     nmo.config = null;
     nmo.load({nmoconf: __dirname + '/fixtures/randomini'}).then(() => {
       nmo.cli.help().then(() => {
@@ -38,17 +34,16 @@ lab.experiment('nmo', () => {
     });
   });
 
-  lab.test('rejects on failure', (done) => {
+  it('rejects on failure', (done) => {
     nmo.load({nmoconf: 'bler'}).catch(() => {
       done();
     });
   });
 
-  lab.test('has a version property', (done) => {
+  it('has a version property', () => {
     nmo.config = null;
-    nmo.load({nmoconf: __dirname + '/fixtures/randomini'}).then(() => {
+    return nmo.load({nmoconf: __dirname + '/fixtures/randomini'}).then(() => {
       assert.ok(nmo.version);
-      done();
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/replicate-from.js
----------------------------------------------------------------------
diff --git a/test/replicate-from.js b/test/replicate-from.js
index 9504bb8..d03d753 100644
--- a/test/replicate-from.js
+++ b/test/replicate-from.js
@@ -1,5 +1,4 @@
 import assert from 'assert';
-import Lab from 'lab';
 
 import { cli } from '../src/replicate-from.js';
 
@@ -8,37 +7,27 @@ import nmo from '../src/nmo.js';
 
 import nock from 'nock';
 
-export let lab = Lab.script();
-const oldConsole = console.log;
 const nmoconf = {nmoconf: __dirname + '/fixtures/randomini'};
 
 common.createConfigFile();
 
-lab.experiment('replicate-from', () => {
+describe('replicate-from', () => {
 
-  lab.experiment('cli', () => {
-    lab.beforeEach((done) => {
-      nmo
-        .load(nmoconf)
-        .then(() => done())
-        .catch(() => done());
-
-    });
-
-    lab.afterEach((done) => {
-      console.log = oldConsole;
-      done();
+  describe('cli', () => {
+    beforeEach(() => {
+      return nmo
+        .load(nmoconf);
     });
 
-    lab.test('returns error on no value provided', done => {
-      cli()
+    it('returns error on no value provided', done => {
+      return cli()
         .catch((err) => {
           assert.ok(err instanceof Error);
           done();
         });
     });
 
-    lab.test('replicates db given cluster details', done => {
+    it('replicates db given cluster details', () => {
       const doc = {
         'source':{
           'url':'http://127.0.0.1/mydb'
@@ -54,14 +43,13 @@ lab.experiment('replicate-from', () => {
         .post('/_replicator', doc)
         .reply(200, {ok: true, id: '123', rev: '123'});
 
-      cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
+      return cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
       .then(resp => {
         assert.ok(resp.ok);
-        done();
       });
     });
 
-    lab.test('replicates db given cluster details with continuous and create_target', done => {
+    it('replicates db given cluster details with continuous and create_target', () => {
       nmo
         .load({nmoconf: __dirname + '/fixtures/randomini', 'create-target': true, continuous: true})
         .then(() => {
@@ -80,10 +68,9 @@ lab.experiment('replicate-from', () => {
             .post('/_replicator', doc)
             .reply(200, {ok: true, id: '123', rev: '123'});
 
-          cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
+          return cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
           .then(resp => {
             assert.ok(resp.ok);
-            done();
           });
         });
     });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/replicate-to.js
----------------------------------------------------------------------
diff --git a/test/replicate-to.js b/test/replicate-to.js
index 7872580..078d307 100644
--- a/test/replicate-to.js
+++ b/test/replicate-to.js
@@ -1,5 +1,4 @@
 import assert from 'assert';
-import Lab from 'lab';
 
 import { cli } from '../src/replicate-to.js';
 
@@ -8,37 +7,26 @@ import nmo from '../src/nmo.js';
 
 import nock from 'nock';
 
-export let lab = Lab.script();
-const oldConsole = console.log;
 const nmoconf = {nmoconf: __dirname + '/fixtures/randomini'};
 
 common.createConfigFile();
 
-lab.experiment('replicate-to', () => {
+describe('replicate-to', () => {
 
-  lab.experiment('cli', () => {
-    lab.beforeEach((done) => {
-      nmo
-        .load(nmoconf)
-        .then(() => done())
-        .catch(() => done());
-
-    });
-
-    lab.afterEach((done) => {
-      console.log = oldConsole;
-      done();
+  describe('cli', () => {
+    beforeEach(() => {
+      return nmo
+        .load(nmoconf);
     });
 
-    lab.test('returns error on no value provided', done => {
-      cli()
+    it('returns error on no value provided', () => {
+      return cli()
         .catch((err) => {
           assert.ok(err instanceof Error);
-          done();
         });
     });
 
-    lab.test('replicates db given cluster details', done => {
+    it('replicates db given cluster details', () => {
       const doc = {
         'target':{
           'url':'http://127.0.0.1/mydb'
@@ -54,15 +42,14 @@ lab.experiment('replicate-to', () => {
         .post('/_replicator', doc)
         .reply(200, {ok: true, id: '123', rev: '123'});
 
-      cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
+      return cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
       .then(resp => {
         assert.ok(resp.ok);
-        done();
       });
     });
 
-    lab.test('replicates db given cluster details with continuous and create_target', done => {
-      nmo
+    it('replicates db given cluster details with continuous and create_target', () => {
+      return nmo
         .load({nmoconf: __dirname + '/fixtures/randomini', 'create-target': true, continuous: true})
         .then(() => {
           const doc = {
@@ -80,10 +67,9 @@ lab.experiment('replicate-to', () => {
             .post('/_replicator', doc)
             .reply(200, {ok: true, id: '123', rev: '123'});
 
-          cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
+          return cli('clusterone', 'mydb', 'https://target-repl.com/new-db')
           .then(resp => {
             assert.ok(resp.ok);
-            done();
           });
         });
     });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/replicate.js
----------------------------------------------------------------------
diff --git a/test/replicate.js b/test/replicate.js
index 013c124..741a6be 100644
--- a/test/replicate.js
+++ b/test/replicate.js
@@ -1,15 +1,12 @@
 import assert from 'assert';
-import Lab from 'lab';
 import nock from 'nock';
 
 import {createReplicatorDoc, replicate} from '../src/replicate.js';
-export let lab = Lab.script();
 
+describe('replicate', () => {
 
-lab.experiment('replicate', () => {
-
-  lab.experiment('createReplicatorDoc', () => {
-    lab.test('creates correctly defined doc', (done) => {
+  describe('createReplicatorDoc', () => {
+    it('creates correctly defined doc', () => {
       var doc = createReplicatorDoc('source-url', 'target-url', {continuous: true, 'create_target': true});
 
       assert.deepEqual({
@@ -24,13 +21,12 @@ lab.experiment('replicate', () => {
         'create_target': true
       }, doc);
 
-      done();
     });
   });
 
-  lab.experiment('replicate', () => {
+  describe('replicate', () => {
 
-    lab.it('returns json response', done => {
+    it('returns json response', () => {
       var data = {ok: true};
       var payload = {
         source: {
@@ -48,27 +44,21 @@ lab.experiment('replicate', () => {
         .post('/_replicator')
         .reply(200, data);
 
-      replicate('http://127.0.0.1/_replicator', payload)
+      return replicate('http://127.0.0.1/_replicator', payload)
       .then(resp => {
         assert.deepEqual(resp, data);
-        done();
       });
-
-
     });
 
-    lab.it('returns error on failed replication', done => {
+    it('returns error on failed replication', () => {
       nock('http://127.0.0.1')
         .post('/_replicator')
         .reply(500, {reason: 'ERROR'});
 
-      replicate('http://127.0.0.1/_replicator', {})
+      return replicate('http://127.0.0.1/_replicator', {})
       .catch(err => {
         assert.deepEqual(err.type, 'EUSAGE');
-        done();
       });
-
     });
-
   });
 });

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/savetofile.js
----------------------------------------------------------------------
diff --git a/test/savetofile.js b/test/savetofile.js
index 307d85a..fd7bab3 100644
--- a/test/savetofile.js
+++ b/test/savetofile.js
@@ -1,5 +1,4 @@
 import assert from 'assert';
-import Lab from 'lab';
 import {unlinkSync, readFileSync } from 'fs';
 
 import savetofile, {cli} from '../src/savetofile.js';
@@ -9,44 +8,37 @@ import nock from 'nock';
 import zlib from 'zlib';
 import { createConfigFile } from './common';
 
-export let lab = Lab.script();
-
-lab.experiment('savetofile', () => {
+describe('savetofile', () => {
   createConfigFile();
-  lab.beforeEach((done) => {
-    nmo
-      .load({nmoconf: __dirname + '/fixtures/randomini'})
-      .then(() => done())
-      .catch(() => done());
+  beforeEach(() => {
+    return nmo
+      .load({nmoconf: __dirname + '/fixtures/randomini'});
   });
 
-  lab.experiment('cli', () => {
+  describe('cli', () => {
 
-    lab.test('Returns error for empty params', done => {
+    it('Returns error for empty params', () => {
       cli().catch(err => {
         assert.ok(/Usage/.test(err.message));
-        done();
       });
     });
 
-    lab.test('Returns error for missing file', done => {
+    it('Returns error for missing file', () => {
       cli('a url').catch(err => {
         assert.ok(/Usage/.test(err.message));
-        done();
       });
     });
 
-    lab.test('returns error with type EUSAGE for any error', done => {
+    it('returns error with type EUSAGE for any error', () => {
       cli('http://127.0.0.1:5555', 'the-db', 'a-file')
       .catch(err => {
         assert.deepEqual(err.type, 'EUSAGE');
-        done();
       });
 
     });
   });
 
-  lab.experiment('savetofile', () => {
+  describe('savetofile', () => {
     const file1 =  __dirname + '/fixtures/delete-me-please.json';
     const file2 = __dirname + '/fixtures/savetofiletest.json';
     const file3 = __dirname + '/fixtures/savetofiletest.json';
@@ -60,28 +52,23 @@ lab.experiment('savetofile', () => {
       }
     }
 
-    lab.afterEach(done => {
+    afterEach(() => {
       deleteFile(file1);
       deleteFile(file2);
       deleteFile(file3);
       deleteFile(file3 + '.gzip');
-      done();
     });
 
-    lab.test('get all docs for db', done => {
+    it('get all docs for db', () => {
       const url = 'http://127.0.1.20';
       nock(url)
         .get('/test-db/_all_docs?include_docs=true')
         .reply(200, []);
 
-      savetofile(url, 'test-db', file1)
-      .then(() => {
-        done();
-      });
-
+      return savetofile(url, 'test-db', file1);
     });
 
-    lab.test('saves contents to file', done => {
+    it('saves contents to file', () => {
       const resp = {
         'total_rows':2,
         'offset':0,
@@ -114,16 +101,15 @@ lab.experiment('savetofile', () => {
         .get('/test-db/_all_docs?include_docs=true')
         .reply(200, resp);
 
-      savetofile(url, 'test-db', file2)
+      return savetofile(url, 'test-db', file2)
       .then(() => {
         const fileContents = readFileSync(file2, 'utf8');
         var rows = resp.rows.map(row => row.doc);
         assert.deepEqual(JSON.parse(fileContents), rows);
-        done();
       });
     });
 
-    lab.test('saves contents to file and zips with --zip', done => {
+    it('saves contents to file and zips with --zip', done => {
       const resp = {
         'total_rows':2,
         'offset':0,
@@ -161,7 +147,7 @@ lab.experiment('savetofile', () => {
           savetofile(url, 'test-db', file3)
           .then(() => {
             zlib.unzip(readFileSync(file3 + '.gzip'), function (err, fileContents) {
-              var rows = resp.rows.map(row => row.doc);
+              const rows = resp.rows.map(row => row.doc);
               assert.deepEqual(JSON.parse(fileContents.toString()), rows);
               done();
             });
@@ -169,13 +155,11 @@ lab.experiment('savetofile', () => {
         });
     });
 
-    lab.test('returns error on failed fetch of data', done => {
-      savetofile('http://127.0.0.1:5555', 'db', 'the-file')
+    it('returns error on failed fetch of data', () => {
+      return savetofile('http://127.0.0.1:5555', 'db', 'the-file')
       .catch(err => {
         assert.ok(/ECONNREFUSED/.test(err.message));
-        done();
       });
-
     });
   });
 

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/utils.js
----------------------------------------------------------------------
diff --git a/test/utils.js b/test/utils.js
index 90fcaf2..1b3b076 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -1,9 +1,6 @@
 import assert from 'assert';
 import nock from 'nock';
 
-import Lab from 'lab';
-export const lab = Lab.script();
-
 import * as utils from '../src/utils.js';
 import * as common from './common.js';
 import nmo from '../src/nmo.js';
@@ -11,142 +8,127 @@ import nmo from '../src/nmo.js';
 const nmoconf = {nmoconf: __dirname + '/fixtures/randomini'};
 common.createConfigFile();
 
-lab.experiment('utils: validUrl', () => {
+describe('utils: validUrl', () => {
 
-  lab.test('checks protocol of url', done => {
+  it('checks protocol of url', () => {
     const err = utils.validUrl('ftp://wrong.com');
 
     assert.ok(/invalid protocol/.test(err.message));
-    done();
   });
 
-  lab.test('returns null if url is valid', done => {
+  it('returns null if url is valid', () => {
     const err = utils.validUrl('http://good.com');
 
     assert.ok(err === null);
-    done();
   });
 
 });
 
-lab.experiment('utils: getClusterUrls', () => {
+describe('utils: getClusterUrls', () => {
 
-  lab.test('getClustersUrl returns correct urls', (done) => {
-    nmo
+  it('getClustersUrl returns correct urls', () => {
+    return nmo
       .load(nmoconf)
       .then(() => {
       const urls = utils.getClusterUrls('clusterone');
       assert.deepEqual(['http://127.0.0.1', 'http://192.168.0.1'], urls);
-      done();
     });
   });
 
-  lab.test('getClustersUrl throws an error if the cluster does not exist', (done) => {
-    nmo
+  it('getClustersUrl throws an error if the cluster does not exist', () => {
+    return nmo
       .load(nmoconf)
       .then(() => {
         return utils.getClusterUrls('doesnt-exist');
       })
       .catch(e => {
         assert.ok(/Cluster does not exist/.test(e.message));
-        done();
       });
   });
 
 });
 
-lab.experiment('utils: getUrlFromCluster', () => {
+describe('utils: getUrlFromCluster', () => {
 
-  lab.test('it returns url for url passed to it', done => {
+  it('it returns url for url passed to it', () => {
     const url = 'http://127.0.0.1';
     const out = utils.getUrlFromCluster(url);
     assert.deepEqual(url, out);
-    done();
   });
 
-  lab.test('returns url for cluster', done => {
+  it('returns url for cluster', () => {
     const out = utils.getUrlFromCluster('clusterone');
     assert.deepEqual('http://127.0.0.1', out);
-    done();
   });
 });
 
-lab.experiment('utils: uri', () => {
+describe('utils: uri', () => {
 
-  lab.test('valid uri', (done) => {
+  it('valid uri', () => {
     assert.ok(utils.isUri('https://example.com:8000'));
-    done();
   });
 
 
-  lab.test('invalid url', (done) => {
+  it('invalid url', () => {
     assert.equal(utils.isUri('example.com'), false);
-    done();
   });
 });
 
-lab.experiment('utils: checkUrl', () => {
+describe('utils: checkUrl', () => {
 
-  lab.test('valid uri', (done) => {
+  it('valid uri', () => {
     assert.ok(utils.checkUrl() instanceof Error);
-    done();
   });
 
 
-  lab.test('invalid url', (done) => {
+  it('invalid url', () => {
     assert.ok(utils.checkUrl('blubb') instanceof Error);
-    done();
   });
 
-  lab.test('valid url', (done) => {
+  it('valid url', () => {
     assert.equal(utils.checkUrl('https://example.com:8000'), null);
-    done();
   });
 });
 
-lab.experiment('utils: send json to node', () => {
+describe('utils: send json to node', () => {
 
-  lab.test('returns error on no value provided', (done) => {
-    utils
+  it('returns error on no value provided', () => {
+    return utils
       .sendJsonToNode()
       .catch((err) => {
         assert.ok(err instanceof Error);
-        done();
       });
   });
 
-  lab.test('returns error for offline nodes', (done) => {
-    utils
+  it('returns error for offline nodes', () => {
+    return utils
       .sendJsonToNode('http://127.0.0.1:65516', {'ok': 'true'})
       .catch((err) => {
         assert.ok(err instanceof Error);
-        done();
       });
   });
 
-  lab.test('returns error for all other errors', (done) => {
-    utils
+  it('returns error for all other errors', () => {
+    return utils
       .sendJsonToNode('http://example.com', '')
       .catch((err) => {
         assert.ok(err instanceof Error);
-        done();
       });
   });
 
-  lab.test('communicates with the server', (done) => {
+  it('communicates with the server', () => {
     nock('http://127.0.0.1:1337')
       .post('/')
       .reply(200, {ok: true, msg: 'hello'});
 
-    utils
+    return utils
       .sendJsonToNode(common.NODE, {'ok': 'true'})
       .then((res) => {
         assert.equal(res.msg, 'hello');
-        done();
       });
   });
 
-  lab.test('sets Content-Type as application/json', done => {
+  it('sets Content-Type as application/json', () => {
     const url = 'http://content-type.test';
     const body = {test: true};
     nock(url,{
@@ -157,21 +139,19 @@ lab.experiment('utils: send json to node', () => {
     .post('/')
     .reply(200);
 
-    utils.sendJsonToNode(url +'/', body)
-    .then(res => { done(); });
+    utils.sendJsonToNode(url +'/', body);
   });
 
-
 });
 
-lab.experiment('utils: removeUsernamePw', () => {
-  lab.test('removes credentials', (done) => {
+describe('utils: removeUsernamePw', () => {
+  it('removes credentials', (done) => {
     var res = utils.removeUsernamePw('https://foo:bar@example.com');
     assert.equal(res, 'https://USER:PW@example.com/');
     done();
   });
 
-  lab.test('keeps other urls valid', (done) => {
+  it('keeps other urls valid', (done) => {
     var res = utils.removeUsernamePw('https://example.com');
     assert.equal(res, 'https://example.com/');
     done();

http://git-wip-us.apache.org/repos/asf/couchdb-nmo/blob/2efbd340/test/v.js
----------------------------------------------------------------------
diff --git a/test/v.js b/test/v.js
index 92685b7..0bf8e20 100644
--- a/test/v.js
+++ b/test/v.js
@@ -1,42 +1,28 @@
 import assert from 'assert';
+import { consoleMock } from './helpers';
 
-import Lab from 'lab';
-export const lab = Lab.script();
-
-import * as version from '../src/v.js';
-import versionApi from '../src/v.js';
+import versionApi, {cli} from '../src/v.js';
 
 import pkg from '../package.json';
 
-const oldConsole = console.log;
 
-lab.experiment('api: version', () => {
+describe('api: version', () => {
 
-  lab.test('gets the current nmo version', (done) => {
-    versionApi().then((res) => {
+  it('gets the current nmo version', () => {
+    return versionApi().then((res) => {
       assert.equal(pkg.version, res.nmo);
-      done();
     });
   });
 });
 
-lab.experiment('cli: version', () => {
-  lab.afterEach((done) => {
-    console.log = oldConsole;
-    done();
-  });
+describe('cli: version', () => {
+
+  it('logs the current version', (done) => {
+    console.log = consoleMock((...args) => {
+      assert.ok(new RegExp(pkg.version, 'ig').test(args[0]));
+      done();
+    });
 
-  lab.test('logs the current version', (done) => {
-    console.log = (...args) => {
-      if (/nmo/.test(args[0])) {
-        assert.ok(new RegExp(pkg.version, 'ig').test(args[0]));
-      }
-    };
-
-    version
-      .cli()
-      .then(() => {
-        done();
-      });
+    return cli();
   });
 });


Mime
View raw message