@@ -148,39 +148,49 @@ const registerHooks = () => {
148148      // we can only request server-side code coverage 
149149      // if we are running end-to-end tests, 
150150      // otherwise where do we send the request? 
151-       const  url  =  Cypress . _ . get ( 
151+       const  captureUrls  =  Cypress . _ . get ( 
152152        Cypress . env ( 'codeCoverage' ) , 
153153        'url' , 
154154        '/__coverage__' 
155155      ) 
156-       cy . request ( { 
157-         url, 
158-         log : false , 
159-         failOnStatusCode : false 
160-       } ) 
161-         . then ( ( r )  =>  { 
162-           return  Cypress . _ . get ( r ,  'body.coverage' ,  null ) 
156+       function  captureCoverage ( url ,  suffix  =  '' )  { 
157+         cy . request ( { 
158+           url, 
159+           log : false , 
160+           failOnStatusCode : false 
163161        } ) 
164-         . then ( ( coverage )  =>  { 
165-           if  ( ! coverage )  { 
166-             // we did not get code coverage - this is the 
167-             // original failed request 
168-             const  expectBackendCoverageOnly  =  Cypress . _ . get ( 
169-               Cypress . env ( 'codeCoverage' ) , 
170-               'expectBackendCoverageOnly' , 
171-               false 
172-             ) 
173-             if  ( expectBackendCoverageOnly )  { 
174-               throw  new  Error ( 
175-                 `Expected to collect backend code coverage from ${ url }  
162+           . then ( ( r )  =>  { 
163+             return  Cypress . _ . get ( r ,  'body.coverage' ,  null ) 
164+           } ) 
165+           . then ( ( coverage )  =>  { 
166+             if  ( ! coverage )  { 
167+               // we did not get code coverage - this is the 
168+               // original failed request 
169+               const  expectBackendCoverageOnly  =  Cypress . _ . get ( 
170+                 Cypress . env ( 'codeCoverage' ) , 
171+                 'expectBackendCoverageOnly' , 
172+                 false 
176173              ) 
177-             }  else  { 
178-               // we did not really expect to collect the backend code coverage 
179-               return 
174+               if  ( expectBackendCoverageOnly )  { 
175+                 throw  new  Error ( 
176+                   `Expected to collect backend code coverage from ${ url }  
177+                 ) 
178+               }  else  { 
179+                 // we did not really expect to collect the backend code coverage 
180+                 return 
181+               } 
180182            } 
181-           } 
182-           sendCoverage ( coverage ,  'backend' ) 
183-         } ) 
183+             sendCoverage ( coverage ,  `backend${ suffix }  ) 
184+           } ) 
185+       } 
186+ 
187+       if  ( Array . isArray ( captureUrls ) )  { 
188+         for  ( const  [ index ,  url ]  of  captureUrls . entries ( ) )  { 
189+           captureCoverage ( url ,  `_${ index }  ) 
190+         } 
191+       }  else  { 
192+         captureCoverage ( captureUrls ) 
193+       } 
184194    } 
185195  } ) 
186196
0 commit comments