@@ -10,6 +10,7 @@ const TEST_FILE = args[0] === '-f' || args[0] === '--fiber'
10
10
? 'fiber'
11
11
: 'stack' ;
12
12
13
+ console . log ( 'Running %s tests' , TEST_FILE ) ;
13
14
const TinyRenderer = require ( './src/' + TEST_FILE ) ;
14
15
const render = TinyRenderer . render ;
15
16
const toJSON = ( props ) => {
@@ -40,12 +41,21 @@ const Rte = (path, component, children) =>
40
41
const ok = [ ] ;
41
42
const fail = [ ] ;
42
43
const skipped = [ ] ;
44
+ const colors = {
45
+ green : '\x1b[32m' ,
46
+ red : '\x1b[31m' ,
47
+ reset : '\x1b[37m' ,
48
+ } ;
49
+
43
50
const it = ( desc , fn ) => {
44
51
try {
45
52
fn . call ( null ) ;
53
+ console . log ( '%s✓ %s%s' , colors . green , colors . reset , desc ) ;
46
54
ok . push ( { desc} ) ;
47
55
} catch ( err ) {
48
56
fail . push ( { desc, err} ) ;
57
+ console . log ( '%s𝘅 %s%s' , colors . red , colors . reset , desc ) ;
58
+ console . error ( '%s. Expected\n %j\n to equal\n %j\n' , err . name , err . actual , err . expected )
49
59
}
50
60
} ;
51
61
@@ -95,10 +105,6 @@ it('should render with a custom toJSON method', () => {
95
105
} ) ;
96
106
97
107
if ( fail . length > 0 ) {
98
- fail . map ( f => {
99
- console . log ( f . desc ) ;
100
- console . error ( '%s. Expected\n %j\n to equal\n %j\n' , f . err . name , f . err . actual , f . err . expected )
101
- } ) ;
102
108
console . log ( '%s tests passed' , ok . length ) ;
103
109
if ( skipped . length ) console . log ( '%s tests skipped' , skipped . length ) ;
104
110
console . log ( '%s tests failed' , fail . length ) ;
@@ -108,3 +114,4 @@ if (fail.length > 0) {
108
114
if ( skipped . length ) console . log ( '%s tests skipped' , skipped . length ) ;
109
115
}
110
116
117
+ console . log ( '' ) ;
0 commit comments