File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,13 @@ var unhandledRejectionCount = 0;
49
49
var uncaughtExceptionCount = 0 ;
50
50
var errors = [ ] ;
51
51
52
- function error ( err ) {
53
- console . error ( err . stack ) ;
52
+ function error ( error ) {
53
+ log . unexpectedExit ( error ) ;
54
+
55
+ // TODO: figure out why this needs to be here to
56
+ // correctly flush the output when multiple test files
57
+ process . stdout . write ( '' ) ;
58
+
54
59
setTimeout ( function ( ) {
55
60
process . exit ( 1 ) ;
56
61
} , 0 ) ;
Original file line number Diff line number Diff line change @@ -58,15 +58,14 @@ x.errors = function (results) {
58
58
var i = 0 ;
59
59
60
60
results . forEach ( function ( result ) {
61
- if ( ! ( result . error && result . error . message ) ) {
61
+ if ( ! result . error ) {
62
62
return ;
63
63
}
64
64
65
65
i ++ ;
66
66
67
67
log . writelpad ( chalk . red ( i + '.' , result . title ) ) ;
68
- log . writelpad ( chalk . red ( beautifyStack ( result . error . stack ) ) ) ;
69
- log . write ( ) ;
68
+ logError ( result . error ) ;
70
69
} ) ;
71
70
} ;
72
71
@@ -90,21 +89,22 @@ x.unhandledRejections = function (file, rejections) {
90
89
}
91
90
rejections . forEach ( function ( rejection ) {
92
91
log . write ( chalk . red ( 'Unhandled Rejection: ' , file ) ) ;
93
- if ( rejection . stack ) {
94
- log . writelpad ( chalk . red ( beautifyStack ( rejection . stack ) ) ) ;
95
- } else {
96
- log . writelpad ( chalk . red ( JSON . stringify ( rejection ) ) ) ;
97
- }
98
- log . write ( ) ;
92
+ logError ( rejection ) ;
99
93
} ) ;
100
94
} ;
101
95
102
96
x . uncaughtException = function ( file , error ) {
103
97
log . write ( chalk . red ( 'Uncaught Exception: ' , file ) ) ;
98
+ logError ( error ) ;
99
+ } ;
100
+
101
+ function logError ( error ) {
104
102
if ( error . stack ) {
105
103
log . writelpad ( chalk . red ( beautifyStack ( error . stack ) ) ) ;
106
104
} else {
107
105
log . writelpad ( chalk . red ( JSON . stringify ( error ) ) ) ;
108
106
}
109
107
log . write ( ) ;
110
- } ;
108
+ }
109
+
110
+ x . unexpectedExit = logError ;
You can’t perform that action at this time.
0 commit comments