@@ -61,16 +61,26 @@ Zone.__load_patch('jasmine', (global: any) => {
61
61
jasmineEnv [ symbol ( methodName ) ] = originalJasmineFn ;
62
62
jasmineEnv [ methodName ] = function (
63
63
description : string , specDefinitions : Function , timeout : number ) {
64
- arguments [ 1 ] = wrapTestInZone ( specDefinitions ) ;
65
- return originalJasmineFn . apply ( this , arguments ) ;
64
+ if ( typeof timeout !== 'number' ) {
65
+ timeout = ( jasmine as any ) [ symbol ( 'mochaTimeout' ) ] ;
66
+ }
67
+ const wrappedSpecDef = wrapTestInZone ( specDefinitions ) ;
68
+ return originalJasmineFn . apply (
69
+ this ,
70
+ typeof timeout === 'number' ? [ description , wrappedSpecDef , timeout ] :
71
+ [ description , wrappedSpecDef ] ) ;
66
72
} ;
67
73
} ) ;
68
74
[ 'beforeEach' , 'afterEach' ] . forEach ( methodName => {
69
75
let originalJasmineFn : Function = jasmineEnv [ methodName ] ;
70
76
jasmineEnv [ symbol ( methodName ) ] = originalJasmineFn ;
71
77
jasmineEnv [ methodName ] = function ( specDefinitions : Function , timeout : number ) {
72
- arguments [ 0 ] = wrapTestInZone ( specDefinitions ) ;
73
- return originalJasmineFn . apply ( this , arguments ) ;
78
+ if ( typeof timeout !== 'number' ) {
79
+ timeout = ( jasmine as any ) [ symbol ( 'mochaTimeout' ) ] ;
80
+ }
81
+ const wrappedSpecDef = wrapTestInZone ( specDefinitions ) ;
82
+ return originalJasmineFn . apply (
83
+ this , typeof timeout === 'number' ? [ wrappedSpecDef , timeout ] : [ wrappedSpecDef ] ) ;
74
84
} ;
75
85
} ) ;
76
86
@@ -81,6 +91,19 @@ Zone.__load_patch('jasmine', (global: any) => {
81
91
*/
82
92
function wrapDescribeInZone ( describeBody : Function ) : Function {
83
93
return function ( ) {
94
+ ( jasmine as any ) [ symbol ( 'mochaTimeout' ) ] = null ;
95
+ if ( this && ! this . timeout ) {
96
+ this . timeout = function ( timeout : number ) {
97
+ ( jasmine as any ) [ symbol ( 'mochaTimeout' ) ] = timeout ;
98
+ }
99
+ }
100
+ if ( this && ! this . skip ) {
101
+ this . skip = function ( ) {
102
+ if ( typeof global [ 'pending' ] === 'function' ) {
103
+ global [ 'pending' ] ( ) ;
104
+ }
105
+ }
106
+ }
84
107
return syncZone . run ( describeBody , this , ( arguments as any ) as any [ ] ) ;
85
108
} ;
86
109
}
0 commit comments