@@ -14,19 +14,117 @@ describe('--debug', function() {
14
14
15
15
it ( 'should invoke --inspect' , function ( done ) {
16
16
invokeMocha (
17
- [ '--debug' , '--file' , DEFAULT_FIXTURE ] ,
17
+ [ '--debug' , DEFAULT_FIXTURE ] ,
18
18
function ( err , res ) {
19
19
if ( err ) {
20
20
return done ( err ) ;
21
21
}
22
- expect ( res , 'to have passed' ) . and (
22
+ expect ( res , 'to contain output' , / D e b u g g e r l i s t e n i n g / i) ;
23
+ done ( ) ;
24
+ } ,
25
+ 'pipe'
26
+ ) ;
27
+ } ) ;
28
+
29
+ it ( 'should invoke --inspect-brk' , function ( done ) {
30
+ var proc = invokeMocha (
31
+ [ '--debug-brk' , DEFAULT_FIXTURE ] ,
32
+ function ( err , res ) {
33
+ if ( err ) {
34
+ return done ( err ) ;
35
+ }
36
+ expect ( res , 'to contain output' , / D e b u g g e r l i s t e n i n g / i) ;
37
+ done ( ) ;
38
+ } ,
39
+ 'pipe'
40
+ ) ;
41
+
42
+ // debugger must be manually killed
43
+ setTimeout ( function ( ) {
44
+ process . kill ( proc . pid , 'SIGINT' ) ;
45
+ } , 2000 ) ;
46
+ } ) ;
47
+
48
+ it ( 'should respect custom host/port' , function ( done ) {
49
+ invokeMocha (
50
+ [ '--debug=127.0.0.1:9229' , DEFAULT_FIXTURE ] ,
51
+ function ( err , res ) {
52
+ if ( err ) {
53
+ return done ( err ) ;
54
+ }
55
+ expect (
56
+ res ,
57
+ 'to contain output' ,
58
+ / D e b u g g e r l i s t e n i n g o n .* 1 2 7 .0 .0 .1 : 9 2 2 9 / i
59
+ ) ;
60
+ done ( ) ;
61
+ } ,
62
+ 'pipe'
63
+ ) ;
64
+ } ) ;
65
+
66
+ it ( 'should warn about incorrect usage for version' , function ( done ) {
67
+ invokeMocha (
68
+ [ '--debug=127.0.0.1:9229' , DEFAULT_FIXTURE ] ,
69
+ function ( err , res ) {
70
+ if ( err ) {
71
+ return done ( err ) ;
72
+ }
73
+ expect ( res , 'to contain output' , / " - - d e b u g " i s n o t a v a i l a b l e / i) ;
74
+ done ( ) ;
75
+ } ,
76
+ 'pipe'
77
+ ) ;
78
+ } ) ;
79
+ } ) ;
80
+
81
+ describe ( 'Node.js v6' , function ( ) {
82
+ // note that v6.3.0 and newer supports --inspect but still supports --debug.
83
+ before ( function ( ) {
84
+ if ( process . version . substring ( 0 , 2 ) !== 'v6' ) {
85
+ this . skip ( ) ;
86
+ }
87
+ } ) ;
88
+
89
+ it ( 'should start debugger' , function ( done ) {
90
+ var proc = invokeMocha (
91
+ [ '--debug' , DEFAULT_FIXTURE ] ,
92
+ function ( err , res ) {
93
+ if ( err ) {
94
+ return done ( err ) ;
95
+ }
96
+ expect ( res , 'to contain output' , / D e b u g g e r l i s t e n i n g / i) ;
97
+ done ( ) ;
98
+ } ,
99
+ 'pipe'
100
+ ) ;
101
+
102
+ // debugger must be manually killed
103
+ setTimeout ( function ( ) {
104
+ process . kill ( proc . pid , 'SIGINT' ) ;
105
+ } , 2000 ) ;
106
+ } ) ;
107
+
108
+ it ( 'should respect custom host/port' , function ( done ) {
109
+ var proc = invokeMocha (
110
+ [ '--debug=127.0.0.1:9229' , DEFAULT_FIXTURE ] ,
111
+ function ( err , res ) {
112
+ if ( err ) {
113
+ return done ( err ) ;
114
+ }
115
+ expect (
116
+ res ,
23
117
'to contain output' ,
24
- / D e b u g g e r l i s t e n i n g / i
118
+ / D e b u g g e r l i s t e n i n g o n . * 1 2 7 . 0 . 0 . 1 : 9 2 2 9 / i
25
119
) ;
26
120
done ( ) ;
27
121
} ,
28
- { stdio : 'pipe' }
122
+ 'pipe'
29
123
) ;
124
+
125
+ setTimeout ( function ( ) {
126
+ process . kill ( proc . pid , 'SIGINT' ) ;
127
+ } , 2000 ) ;
30
128
} ) ;
31
129
} ) ;
32
130
} ) ;
0 commit comments