@@ -75,13 +75,15 @@ export default async (options: IOptions) => {
7575 rules = options . rules ;
7676 }
7777
78- for ( const reporter of options . reporters ) {
79- reporter . onBegin ( options , calls ) ;
80- }
78+ await Promise . all (
79+ options . reporters . map ( ( reporter ) =>
80+ Promise . resolve ( reporter . onBegin ( options , calls ) )
81+ )
82+ ) ;
8183
82- for ( const rule of rules ) {
83- await Promise . resolve ( rule . onBegin ?.( options ) ) ;
84- }
84+ await Promise . all (
85+ rules . map ( ( rule ) => Promise . resolve ( rule . onBegin ?.( options ) ) )
86+ ) ;
8587
8688 // getCalls could be async or sync
8789 const callsPromises = await Promise . all ( filteredMethods . map ( ( method ) =>
@@ -109,9 +111,11 @@ export default async (options: IOptions) => {
109111 getCallsEnd : Date . now ( ) ,
110112 }
111113 }
112- for ( const reporter of options . reporters ) {
113- reporter . onTestBegin ( options , call ) ;
114- }
114+ await Promise . all (
115+ options . reporters . map ( ( reporter ) =>
116+ Promise . resolve ( reporter . onTestBegin ( options , call ) )
117+ )
118+ ) ;
115119 if ( call . timings ) {
116120 call . timings . beforeRequestStart = Date . now ( ) ;
117121 }
@@ -161,17 +165,21 @@ export default async (options: IOptions) => {
161165 call . timings . afterResponseEnd = Date . now ( ) ;
162166 call . timings . endTime = Date . now ( ) ;
163167 }
164- for ( const reporter of options . reporters ) {
165- reporter . onTestEnd ( options , call ) ;
166- }
168+ await Promise . all (
169+ options . reporters . map ( ( reporter ) =>
170+ Promise . resolve ( reporter . onTestEnd ( options , call ) )
171+ )
172+ ) ;
167173 }
168174
169- for ( const rule of rules ) {
170- await Promise . resolve ( rule . onEnd ?.( options , calls ) ) ;
171- }
175+ await Promise . all (
176+ rules . map ( ( rule ) => Promise . resolve ( rule . onEnd ?.( options , calls ) ) )
177+ ) ;
172178
173- for ( const reporter of options . reporters ) {
174- reporter . onEnd ( options , calls ) ;
175- }
179+ await Promise . all (
180+ options . reporters . map ( ( reporter ) =>
181+ Promise . resolve ( reporter . onEnd ( options , calls ) )
182+ )
183+ ) ;
176184 return calls ;
177185} ;
0 commit comments