@@ -54,12 +54,20 @@ export default async (options: IOptions) => {
5454 rules = options . rules ;
5555 }
5656
57- filteredMethods . forEach ( ( method ) => {
58- rules . forEach ( ( rule ) =>
59- rule . getExampleCalls ( options . openrpcDocument , method )
60- . forEach ( ( exampleCall ) => exampleCalls . push ( { ...exampleCall , rule} ) )
61- ) ;
62- } ) ;
57+ // getExampleCalls could be async or sync
58+ const exampleCallsPromises = await Promise . all ( filteredMethods . map ( ( method ) =>
59+ Promise . all (
60+ rules . map ( async ( rule ) => {
61+ const calls = await Promise . resolve ( rule . getExampleCalls ( options . openrpcDocument , method ) )
62+ calls . forEach ( ( call ) => {
63+ call . rule = rule ;
64+ } ) ;
65+ return calls ;
66+ }
67+ )
68+ )
69+ ) ) ;
70+ exampleCalls . push ( ...exampleCallsPromises . flat ( ) . flat ( ) ) ;
6371
6472 for ( const reporter of options . reporters ) {
6573 reporter . onBegin ( options , exampleCalls ) ;
@@ -86,7 +94,9 @@ export default async (options: IOptions) => {
8694 exampleCall . valid = false ;
8795 exampleCall . requestError = e ;
8896 }
89- exampleCall . requestError ?? await Promise . resolve ( exampleCall . rule ?. validateExampleCall ?.( exampleCall ) ) ;
97+ if ( exampleCall . requestError === undefined ) {
98+ await Promise . resolve ( exampleCall . rule ?. validateExampleCall ?.( exampleCall ) ) ;
99+ }
90100 await Promise . resolve ( exampleCall . rule ?. afterResponse ?.( options , exampleCall ) ) ;
91101 for ( const reporter of options . reporters ) {
92102 reporter . onTestEnd ( options , exampleCall ) ;
0 commit comments