@@ -12,9 +12,10 @@ const defineProperty = Object[zoneSymbol('defineProperty')] || Object.defineProp
1212describe ( 'longStackTraceZone' , function ( ) {
1313 let log : Error [ ] ;
1414 let lstz : Zone ;
15+ let longStackTraceZoneSpec = Zone [ 'longStackTraceZoneSpec' ] ;
1516
1617 beforeEach ( function ( ) {
17- lstz = Zone . current . fork ( Zone [ ' longStackTraceZoneSpec' ] ) . fork ( {
18+ lstz = Zone . current . fork ( longStackTraceZoneSpec ) . fork ( {
1819 name : 'long-stack-trace-zone-test' ,
1920 onHandleError : ( parentZoneDelegate : ZoneDelegate , currentZone : Zone , targetZone : Zone ,
2021 error : any ) : boolean => {
@@ -67,7 +68,7 @@ describe('longStackTraceZone', function() {
6768 } ) ;
6869 } ) ;
6970
70- it ( 'should produce long stack traces when reject in promise' , function ( done ) {
71+ it ( 'should produce long stack traces when has uncaught error in promise' , function ( done ) {
7172 lstz . runGuarded ( function ( ) {
7273 setTimeout ( function ( ) {
7374 setTimeout ( function ( ) {
@@ -91,6 +92,26 @@ describe('longStackTraceZone', function() {
9192 } , 0 ) ;
9293 } ) ;
9394 } ) ;
95+
96+ it ( 'should produce long stack traces when handling error in promise' , function ( done ) {
97+ lstz . runGuarded ( function ( ) {
98+ setTimeout ( function ( ) {
99+ setTimeout ( function ( ) {
100+ let promise = new Promise ( function ( resolve , reject ) {
101+ setTimeout ( function ( ) {
102+ reject ( new Error ( 'Hello Promise' ) ) ;
103+ } , 0 ) ;
104+ } ) ;
105+ promise . catch ( function ( error ) {
106+ // should be able to get long stack trace
107+ const longStackFrames : string = longStackTraceZoneSpec . getLongStackTrace ( error ) ;
108+ expect ( longStackFrames . split ( 'Elapsed: ' ) . length ) . toBe ( 4 ) ;
109+ done ( ) ;
110+ } ) ;
111+ } , 0 ) ;
112+ } , 0 ) ;
113+ } ) ;
114+ } ) ;
94115} ) ;
95116
96117export let __something__ ;
0 commit comments