Skip to content

Commit

Permalink
Merge pull request #278 from geek/master
Browse files Browse the repository at this point in the history
Fix before/after exceptions to be reported
  • Loading branch information
Eran Hammer committed Nov 22, 2014
2 parents b0b7928 + 47e3fa7 commit d750082
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/runner.js
Expand Up @@ -240,7 +240,7 @@ internals.executeDeps = function (deps, state, callback) {
}, timeout);
}

dep.fn.call(null, finish);
internals.protect(dep, state, finish);
}, callback);
};

Expand Down
23 changes: 23 additions & 0 deletions test/cli.js
Expand Up @@ -97,6 +97,29 @@ describe('CLI', function () {
});
});

it('exits with code 1 when after function throws', function (done) {

var cli = ChildProcess.spawn('node', [labPath, 'test/cli_throws/throws.js']);
var outData = '';
var errData = '';

cli.stdout.on('data', function (data) {

outData += data;
});

cli.stderr.on('data', function (data) {

errData += data;
});

cli.once('close', function (code) {

expect(code).to.not.equal(0);
done();
});
});

it('shows the help (-h)', function (done) {

var cli = ChildProcess.spawn('node', [labPath,'-h']);
Expand Down
31 changes: 31 additions & 0 deletions test/cli_throws/throws.js
@@ -0,0 +1,31 @@
// Load modules

var _Lab = require('../../test_runner');


// Declare internals

var internals = {};


// Test shortcuts

var lab = exports.lab = _Lab.script();
var after = lab.after;
var describe = lab.describe;
var it = lab.it;


describe('Test CLI throws', function () {

after(function (done) {

throw new Error('throwing after');
});

it('handles thrown error', function (done) {

done();
});
});

0 comments on commit d750082

Please sign in to comment.