Skip to content

Commit

Permalink
Child tests should inherit bail-on-fail from parent
Browse files Browse the repository at this point in the history
Unless explicitly specified in options object.
  • Loading branch information
isaacs committed Jul 1, 2016
1 parent ec90a96 commit 1f88f4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Test.prototype.test = function test (name, extra, cb, deferred) {

child._name = name
child._parent = this
if (this._bail) {
if (!Object.prototype.hasOwnProperty.call(extra, 'bail')) {
child._bail = this._bail
}

Expand Down
12 changes: 8 additions & 4 deletions test/throw-after-end.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
var t = require('../')
var Test = t.Test

var tt = new Test()
var tt = new Test({ bail: false })
tt._name = 'one'
tt.pass('this is fine')
tt.end()
t.throws(function () {
tt.threw(new Error('whoops'))
}, { message: 'whoops', stack: /^Error: whoops\n/ })

var out = ''
tt = new Test()
tt = new Test({ bail: false })
tt._name = 'two'

tt.on('data', function (c) {
out += c
})
tt.test(function (tt) {
tt.test('child', function (tt) {
tt.threw(new Error('whoops'))
tt.end()
})
tt.end()

t.match(out, '\n not ok 1 - Error: whoops\n')
t.match(out, '\n tt.threw(new Error(\'whoops\'))\n')
t.match(out, '\nnot ok 1 - (unnamed test) # time=')
t.match(out, '\nnot ok 1 - child # time=')

0 comments on commit 1f88f4a

Please sign in to comment.