Skip to content

Commit

Permalink
Handle unfinished promise-awaiting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 10, 2016
1 parent 3971c06 commit b5a18bf
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ Test.prototype.endAll = function () {
child._bailedOut = true
}

this._mustDeferEnd = false
this.end(IMPLICIT)
}

Expand Down
13 changes: 13 additions & 0 deletions test/test/unfinished-promise-bail.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
TAP version 13
# Subtest: parent
# Subtest: child
# Subtest: grandchild
1..2
ok 1 - ok
not ok 2 - test unfinished: grandchild
---
{"at":{"column":14,"file":"test/test/unfinished-promise.js","line":4},"count":1,"plan":2,"source":"return t.test('grandchild', function (t) {\n"}
...
Bail out! # test unfinished: grandchild
Bail out! # test unfinished: grandchild

9 changes: 9 additions & 0 deletions test/test/unfinished-promise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var t = require('../..')
t.test('parent', function (t) {
return t.test('child', function (t) {
return t.test('grandchild', function (t) {
t.plan(2)
t.pass('ok')
})
})
})
34 changes: 34 additions & 0 deletions test/test/unfinished-promise.tap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
TAP version 13
# Subtest: parent
# Subtest: child
# Subtest: grandchild
1..2
ok 1 - ok
not ok 2 - test unfinished: grandchild
---
{"at":{"column":14,"file":"test/test/unfinished-promise.js","line":4},"count":1,"plan":2,"source":"return t.test('grandchild', function (t) {\n"}
...
# failed 1 of 2 tests
not ok 1 - grandchild ___/# time=[0-9.]+(ms)?/~~~
---
{"at":{"column":14,"file":"test/test/unfinished-promise.js","line":4},"results":{"count":2,"fail":1,"ok":false,"pass":1,"plan":{"end":2,"start":1}},"source":"return t.test('grandchild', function (t) {\n"}
...

1..1
# failed 1 of 1 tests
not ok 1 - child ___/# time=[0-9.]+(ms)?/~~~
---
{"at":{"column":12,"file":"test/test/unfinished-promise.js","line":3},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"return t.test('child', function (t) {\n"}
...

1..1
# failed 1 of 1 tests
not ok 1 - parent ___/# time=[0-9.]+(ms)?/~~~
---
{"at":{"column":3,"file":"test/test/unfinished-promise.js","line":2},"results":{"count":1,"fail":1,"ok":false,"pass":0,"plan":{"end":1,"start":1}},"source":"t.test('parent', function (t) {\n"}
...

1..1
# failed 1 of 1 tests
___/# time=[0-9.]+(ms)?/~~~

0 comments on commit b5a18bf

Please sign in to comment.