Skip to content

Commit 840fd12

Browse files
committedJul 1, 2016
adds 'diagnostic' flag to include diags always
Passing tests typically don't get a yaml diagnostic block. With this, you can pass `diagnostic:true` to include a yaml block regardless of whether the test is a pass or fail. Fix #243
1 parent a5d8cee commit 840fd12

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed
 

‎lib/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ Test.prototype.printResult = function printResult (ok, message, extra) {
13501350
this.push('\n')
13511351

13521352
// If we're skipping, no need for diags.
1353-
if (!ok && !extra.skip) {
1353+
if (!ok && !extra.skip || extra.diagnostic) {
13541354
this.writeDiags(extra)
13551355
}
13561356

@@ -1377,6 +1377,7 @@ function yamlFilter (propertyName, isRoot, source, target) {
13771377

13781378
return !(propertyName === 'todo' ||
13791379
propertyName === 'skip' ||
1380+
propertyName === 'diagnostic' ||
13801381
(propertyName === 'at' && !source[propertyName]))
13811382
}
13821383

‎test/test/ok-diags-bail.tap

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
TAP version 13
2+
ok 1 - this is fine
3+
---
4+
{"foo":{"bar":"baz"}}
5+
...
6+
# Subtest: child
7+
1..1
8+
ok 1 - this is fine
9+
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~
10+
---
11+
{"at":{"column":3,"file":"test/test/ok-diags.js","line":10},"results":{"count":1,"ok":true,"pass":1,"plan":{"end":1,"start":1}},"source":"t.test('child', { diagnostic: true }, function (t) {\n"}
12+
...
13+
14+
1..2
15+
___/# time=[0-9.]+(ms)?/~~~
16+

‎test/test/ok-diags.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var t = require('../..')
2+
3+
t.pass('this is fine',{
4+
diagnostic: true,
5+
foo: {
6+
bar: 'baz'
7+
}
8+
})
9+
10+
t.test('child', { diagnostic: true }, function (t) {
11+
t.plan(1)
12+
t.pass('this is fine')
13+
})

‎test/test/ok-diags.tap

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
TAP version 13
2+
ok 1 - this is fine
3+
---
4+
{"foo":{"bar":"baz"}}
5+
...
6+
# Subtest: child
7+
1..1
8+
ok 1 - this is fine
9+
ok 2 - child ___/# time=[0-9.]+(ms)?/~~~
10+
---
11+
{"at":{"column":3,"file":"test/test/ok-diags.js","line":10},"results":{"count":1,"ok":true,"pass":1,"plan":{"end":1,"start":1}},"source":"t.test('child', { diagnostic: true }, function (t) {\n"}
12+
...
13+
14+
1..2
15+
___/# time=[0-9.]+(ms)?/~~~
16+

0 commit comments

Comments
 (0)
Please sign in to comment.