@@ -75,22 +75,51 @@ describe('Runner', function(){
75
75
it ( 'should execute afterEach after every it' , function ( ) {
76
76
Describe ( 'describe name' , function ( ) {
77
77
AfterEach ( logger ( 'after;' ) ) ;
78
- It ( 'should text ' , logger ( 'body ;' ) ) ;
78
+ It ( 'should text1 ' , logger ( 'body1 ;' ) ) ;
79
79
It ( 'should text2' , logger ( 'body2;' ) ) ;
80
80
} ) ;
81
- expect ( log ) . toEqual ( 'body ;after;body2;after;' ) ;
81
+ expect ( log ) . toEqual ( 'body1 ;after;body2;after;' ) ;
82
82
} ) ;
83
83
84
84
it ( 'should always execute afterEach after every it' , function ( ) {
85
85
Describe ( 'describe name' , function ( ) {
86
86
AfterEach ( logger ( 'after;' ) ) ;
87
87
It ( 'should text' , function ( ) {
88
- log = 'body;' ;
88
+ logger ( 'body1;' ) ( ) ;
89
89
throw "MyError" ;
90
90
} ) ;
91
91
It ( 'should text2' , logger ( 'body2;' ) ) ;
92
92
} ) ;
93
- expect ( log ) . toEqual ( 'body;after;body2;after;' ) ;
93
+ expect ( log ) . toEqual ( 'body1;after;body2;after;' ) ;
94
+ } ) ;
95
+
96
+ it ( 'should report an error if afterEach fails' , function ( ) {
97
+ var next ;
98
+ Describe ( 'describe name' , function ( ) {
99
+ AfterEach ( function ( ) {
100
+ $scenario . addStep ( 'afterEachLog' , logger ( 'after;' ) ) ;
101
+ $scenario . addStep ( 'afterEachThrow' , function ( ) {
102
+ throw "AfterError" ;
103
+ } ) ;
104
+ } ) ;
105
+ It ( 'should text1' , function ( ) {
106
+ $scenario . addStep ( 'step1' , logger ( 'step1;' ) ) ;
107
+ } ) ;
108
+ It ( 'should text2' , function ( ) {
109
+ $scenario . addStep ( 'step2' , logger ( 'step2;' ) ) ;
110
+ } ) ;
111
+ } ) ;
112
+ $scenario . run ( body ) ;
113
+ expect ( log ) . toEqual ( 'step1;after;step2;after;' ) ;
114
+ expect ( scenario . $testrun . results ) . toEqual ( [
115
+ { name : 'describe name: it should text1' ,
116
+ passed : false ,
117
+ error : 'AfterError' ,
118
+ steps : [ 'step1' , 'afterEachLog' , 'afterEachThrow' ] } ,
119
+ { name : 'describe name: it should text2' ,
120
+ passed : false ,
121
+ error : 'AfterError' ,
122
+ steps : [ 'step2' , 'afterEachLog' , 'afterEachThrow' ] } ] ) ;
94
123
} ) ;
95
124
} ) ;
96
125
} ) ;
0 commit comments