File tree 2 files changed +27
-11
lines changed
2 files changed +27
-11
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
+ - fixes issue when no assert name is provided
4
+ - fixes issue when no test name is provided with TAP comment
3
5
- Change behavior when no output file is given to tap-html to restore what is described in README.md
4
6
5
7
# 1.0.1 (04/20/2019)
Original file line number Diff line number Diff line change @@ -14,19 +14,23 @@ module.exports = function tapHTML (callback) {
14
14
15
15
const startTime = Date . now ( ) ;
16
16
17
+ function pushTest ( name ) {
18
+ data . push ( {
19
+ type : 'test' ,
20
+ name : name ,
21
+ start : Date . now ( ) ,
22
+ assertions : [ ]
23
+ } ) ;
24
+
25
+ // get the current index of the plan
26
+ // so that we can use this to push the current assertions to it
27
+ currentPlan += 1 ;
28
+ currentAssertion = - 1 ;
29
+ }
30
+
17
31
tap . on ( 'comment' , ( res ) => {
18
32
if ( ! plan ) {
19
- data . push ( {
20
- type : 'test' ,
21
- name : res ,
22
- start : Date . now ( ) ,
23
- assertions : [ ]
24
- } ) ;
25
-
26
- // get the current index of the plan
27
- // so that we can use this to push the current assertions to it
28
- currentPlan += 1 ;
29
- currentAssertion = - 1 ;
33
+ pushTest ( res ) ;
30
34
}
31
35
} ) ;
32
36
@@ -43,6 +47,16 @@ module.exports = function tapHTML (callback) {
43
47
} ) ;
44
48
45
49
tap . on ( 'assert' , ( res ) => {
50
+ // If no plan is registered yet, create a default plan.
51
+ if ( currentPlan == - 1 ) {
52
+ pushTest ( 'default' ) ;
53
+ }
54
+
55
+ // TAP does not require a name. If no name is registered, set a default name.
56
+ if ( ! res . name ) {
57
+ res . name = 'test #' + res . id ;
58
+ }
59
+
46
60
data [ currentPlan ] . assertions . push ( {
47
61
type : 'assert' ,
48
62
number : res . id ,
You can’t perform that action at this time.
0 commit comments