22var chalk = require ( 'chalk' ) ;
33var test = require ( 'tap' ) . test ;
44var AvaError = require ( '../../lib/ava-error' ) ;
5- var miniReporter = require ( '../../lib/reporters/mini' ) ;
5+ var _miniReporter = require ( '../../lib/reporters/mini' ) ;
66var beautifyStack = require ( '../../lib/beautify-stack' ) ;
77
8+ function miniReporter ( ) {
9+ var reporter = _miniReporter ( ) ;
10+ reporter . start = function ( ) {
11+ return '' ;
12+ } ;
13+ return reporter ;
14+ }
15+
816process . stderr . setMaxListeners ( 50 ) ;
917
1018test ( 'start' , function ( t ) {
11- var reporter = miniReporter ( ) ;
19+ var reporter = _miniReporter ( ) ;
1220
13- t . is ( reporter . start ( ) , '' ) ;
21+ t . is ( reporter . start ( ) , ' \n ⠋ ' ) ;
22+ reporter . clearInterval ( ) ;
1423 t . end ( ) ;
1524} ) ;
1625
@@ -22,9 +31,10 @@ test('passing test', function (t) {
2231 } ) ;
2332
2433 var expectedOutput = [
25- ' ' + chalk . green ( 'passed' ) ,
34+ ' ' ,
35+ ' ⠋ ' + chalk . green ( 'passed' ) ,
2636 '' ,
27- ' ' + chalk . green ( '1 passed' )
37+ ' ' + chalk . green ( '1 passed' )
2838 ] . join ( '\n' ) ;
2939
3040 t . is ( actualOutput , expectedOutput ) ;
@@ -42,9 +52,58 @@ test('failing test', function (t) {
4252 } ) ;
4353
4454 var expectedOutput = [
45- ' ' + chalk . red ( 'failed' ) ,
55+ ' ' ,
56+ ' ⠋ ' + chalk . red ( 'failed' ) ,
57+ '' ,
58+ ' ' + chalk . red ( '1 failed' )
59+ ] . join ( '\n' ) ;
60+
61+ t . is ( actualOutput , expectedOutput ) ;
62+ t . end ( ) ;
63+ } ) ;
64+
65+ test ( 'passing test after failing' , function ( t ) {
66+ var reporter = miniReporter ( ) ;
67+
68+ reporter . test ( {
69+ title : 'failed' ,
70+ error : {
71+ message : 'assertion failed'
72+ }
73+ } ) ;
74+
75+ var actualOutput = reporter . test ( { title : 'passed' } ) ;
76+
77+ var expectedOutput = [
78+ ' ' ,
79+ ' ⠋ ' + chalk . green ( 'passed' ) ,
80+ '' ,
81+ ' ' + chalk . green ( '1 passed' ) ,
82+ ' ' + chalk . red ( '1 failed' )
83+ ] . join ( '\n' ) ;
84+
85+ t . is ( actualOutput , expectedOutput ) ;
86+ t . end ( ) ;
87+ } ) ;
88+
89+ test ( 'failing test after passing' , function ( t ) {
90+ var reporter = miniReporter ( ) ;
91+
92+ reporter . test ( { title : 'passed' } ) ;
93+
94+ var actualOutput = reporter . test ( {
95+ title : 'failed' ,
96+ error : {
97+ message : 'assertion failed'
98+ }
99+ } ) ;
100+
101+ var expectedOutput = [
102+ ' ' ,
103+ ' ⠋ ' + chalk . red ( 'failed' ) ,
46104 '' ,
47- ' ' + chalk . red ( '1 failed' )
105+ ' ' + chalk . green ( '1 passed' ) ,
106+ ' ' + chalk . red ( '1 failed' )
48107 ] . join ( '\n' ) ;
49108
50109 t . is ( actualOutput , expectedOutput ) ;
@@ -60,9 +119,10 @@ test('skipped test', function (t) {
60119 } ) ;
61120
62121 var expectedOutput = [
63- ' ' + chalk . yellow ( '- skipped' ) ,
122+ ' ' ,
123+ ' ⠋ ' + chalk . yellow ( '- skipped' ) ,
64124 '' ,
65- ''
125+ ' ' + chalk . yellow ( '1 skipped' )
66126 ] . join ( '\n' ) ;
67127
68128 t . is ( actualOutput , expectedOutput ) ;
@@ -79,9 +139,10 @@ test('todo test', function (t) {
79139 } ) ;
80140
81141 var expectedOutput = [
82- ' ' + chalk . blue ( '- todo' ) ,
142+ ' ' ,
143+ ' ⠋ ' + chalk . blue ( '- todo' ) ,
83144 '' ,
84- ''
145+ ' ' + chalk . blue ( '1 todo' )
85146 ] . join ( '\n' ) ;
86147
87148 t . is ( actualOutput , expectedOutput ) ;
@@ -95,7 +156,7 @@ test('results with passing tests', function (t) {
95156
96157 var actualOutput = reporter . finish ( ) ;
97158 var expectedOutput = [
98- '\n ' + chalk . green ( '1 passed' ) ,
159+ '\n ' + chalk . green ( '1 passed' ) ,
99160 ''
100161 ] . join ( '\n' ) ;
101162
@@ -111,7 +172,7 @@ test('results with skipped tests', function (t) {
111172
112173 var actualOutput = reporter . finish ( ) ;
113174 var expectedOutput = [
114- '\n ' + chalk . yellow ( '1 skipped' ) ,
175+ '\n ' + chalk . yellow ( '1 skipped' ) ,
115176 ''
116177 ] . join ( '\n' ) ;
117178
@@ -127,7 +188,7 @@ test('results with todo tests', function (t) {
127188
128189 var actualOutput = reporter . finish ( ) ;
129190 var expectedOutput = [
130- '\n ' + chalk . blue ( '1 todo' ) ,
191+ '\n ' + chalk . blue ( '1 todo' ) ,
131192 ''
132193 ] . join ( '\n' ) ;
133194
@@ -143,8 +204,9 @@ test('results with passing skipped tests', function (t) {
143204 var output = reporter . finish ( ) . split ( '\n' ) ;
144205
145206 t . is ( output [ 0 ] , '' ) ;
146- t . is ( output [ 1 ] , ' ' + chalk . green ( '1 passed' ) + ' ' + chalk . yellow ( '1 skipped' ) ) ;
147- t . is ( output [ 2 ] , '' ) ;
207+ t . is ( output [ 1 ] , ' ' + chalk . green ( '1 passed' ) ) ;
208+ t . is ( output [ 2 ] , ' ' + chalk . yellow ( '1 skipped' ) ) ;
209+ t . is ( output [ 3 ] , '' ) ;
148210 t . end ( ) ;
149211} ) ;
150212
@@ -164,8 +226,8 @@ test('results with passing tests and rejections', function (t) {
164226 var output = reporter . finish ( ) . split ( '\n' ) ;
165227
166228 t . is ( output [ 0 ] , '' ) ;
167- t . is ( output [ 1 ] , ' ' + chalk . green ( '1 passed' ) ) ;
168- t . is ( output [ 2 ] , ' ' + chalk . red ( '1 rejection' ) ) ;
229+ t . is ( output [ 1 ] , ' ' + chalk . green ( '1 passed' ) ) ;
230+ t . is ( output [ 2 ] , ' ' + chalk . red ( '1 rejection' ) ) ;
169231 t . is ( output [ 3 ] , '' ) ;
170232 t . is ( output [ 4 ] , ' ' + chalk . red ( '1. Unhandled Rejection' ) ) ;
171233 t . match ( output [ 5 ] , / E r r o r : f a i l u r e / ) ;
@@ -192,8 +254,8 @@ test('results with passing tests and exceptions', function (t) {
192254 var output = reporter . finish ( ) . split ( '\n' ) ;
193255
194256 t . is ( output [ 0 ] , '' ) ;
195- t . is ( output [ 1 ] , ' ' + chalk . green ( '1 passed' ) ) ;
196- t . is ( output [ 2 ] , ' ' + chalk . red ( '2 exceptions' ) ) ;
257+ t . is ( output [ 1 ] , ' ' + chalk . green ( '1 passed' ) ) ;
258+ t . is ( output [ 2 ] , ' ' + chalk . red ( '2 exceptions' ) ) ;
197259 t . is ( output [ 3 ] , '' ) ;
198260 t . is ( output [ 4 ] , ' ' + chalk . red ( '1. Uncaught Exception' ) ) ;
199261 t . match ( output [ 5 ] , / E r r o r : f a i l u r e / ) ;
@@ -220,7 +282,7 @@ test('results with errors', function (t) {
220282 var output = reporter . finish ( ) . split ( '\n' ) ;
221283
222284 t . is ( output [ 0 ] , '' ) ;
223- t . is ( output [ 1 ] , ' ' + chalk . red ( '1 failed' ) ) ;
285+ t . is ( output [ 1 ] , ' ' + chalk . red ( '1 failed' ) ) ;
224286 t . is ( output [ 2 ] , '' ) ;
225287 t . is ( output [ 3 ] , ' ' + chalk . red ( '1. failed' ) ) ;
226288 t . match ( output [ 4 ] , / f a i l u r e / ) ;
0 commit comments