(url: string, suffix = '')
| 216 | '/__coverage__' |
| 217 | ) |
| 218 | function captureCoverage(url: string, suffix = ''): void { |
| 219 | cy.request({ |
| 220 | url, |
| 221 | log: false, |
| 222 | failOnStatusCode: false |
| 223 | }) |
| 224 | .then((r) => { |
| 225 | return Cypress._.get(r, 'body.coverage', null) |
| 226 | }) |
| 227 | .then((coverage) => { |
| 228 | if (!coverage) { |
| 229 | // we did not get code coverage - this is the |
| 230 | // original failed request |
| 231 | const expectBackendCoverageOnly = Cypress._.get( |
| 232 | Cypress.expose('codeCoverage'), |
| 233 | 'expectBackendCoverageOnly', |
| 234 | false |
| 235 | ) |
| 236 | if (expectBackendCoverageOnly) { |
| 237 | throw new Error( |
| 238 | `Expected to collect backend code coverage from ${url}` |
| 239 | ) |
| 240 | } else { |
| 241 | // we did not really expect to collect the backend code coverage |
| 242 | return |
| 243 | } |
| 244 | } |
| 245 | sendCoverage(coverage, `backend${suffix}`) |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | if (Array.isArray(captureUrls)) { |
| 250 | for (const [index, url] of captureUrls.entries()) { |
no test coverage detected
searching dependent graphs…