@@ -15,12 +15,20 @@ function apply() {
15
15
var originalIt = global . it ;
16
16
var originalFit = global . fit ;
17
17
18
+ // Patch jasmine `done()` and `done.fail()` so that they execute in the root zone
19
+ var patchJasmineDone = function ( jasmineDone ) {
20
+ var done = jasmineZone . bind ( jasmineDone ) ;
21
+ if ( typeof jasmineDone . fail === 'function' ) {
22
+ done . fail = jasmineZone . bind ( jasmineDone . fail ) ;
23
+ }
24
+
25
+ return done ;
26
+ }
27
+
18
28
global . it = function zoneResettingIt ( description , specFn , timeOut ) {
19
29
if ( specFn . length ) {
20
- originalIt ( description , function zoneResettingSpecFn ( originalDone ) {
21
- specFn ( function zoneResettingDone ( ) {
22
- jasmineZone . run ( originalDone ) ;
23
- } ) ;
30
+ originalIt ( description , function zoneResettingSpecFn ( done ) {
31
+ specFn ( patchJasmineDone ( done ) ) ;
24
32
} , timeOut ) ;
25
33
} else {
26
34
originalIt ( description , specFn , timeOut ) ;
@@ -29,10 +37,8 @@ function apply() {
29
37
30
38
global . fit = function zoneResettingFit ( description , specFn , timeOut ) {
31
39
if ( specFn . length ) {
32
- originalFit ( description , function zoneResettingSpecFn ( originalDone ) {
33
- specFn ( function zoneResettingDone ( ) {
34
- jasmineZone . run ( originalDone ) ;
35
- } ) ;
40
+ originalFit ( description , function zoneResettingSpecFn ( done ) {
41
+ specFn ( patchJasmineDone ( done ) ) ;
36
42
} , timeOut ) ;
37
43
} else {
38
44
originalFit ( description , specFn , timeOut ) ;
0 commit comments