(testModules: ReadonlyArray<TestModule>)
| 290 | } |
| 291 | |
| 292 | async onTestRunEnd(testModules: ReadonlyArray<TestModule>): Promise<void> { |
| 293 | const files = testModules.map(testModule => testModule.task) |
| 294 | |
| 295 | await this.logger.log('<?xml version="1.0" encoding="UTF-8" ?>') |
| 296 | |
| 297 | const transformed = files.map((file) => { |
| 298 | const tasks = file.tasks.flatMap(task => flattenTasks(task)) |
| 299 | |
| 300 | const stats = tasks.reduce( |
| 301 | (stats, task) => { |
| 302 | return { |
| 303 | passed: stats.passed + Number(task.result?.state === 'pass'), |
| 304 | failures: stats.failures + Number(task.result?.state === 'fail'), |
| 305 | skipped: |
| 306 | stats.skipped |
| 307 | + Number(task.mode === 'skip' || task.mode === 'todo'), |
| 308 | } |
| 309 | }, |
| 310 | { |
| 311 | passed: 0, |
| 312 | failures: 0, |
| 313 | skipped: 0, |
| 314 | }, |
| 315 | ) |
| 316 | |
| 317 | // inject failed suites to surface errors during beforeAll/afterAll |
| 318 | const suites = getSuites(file) |
| 319 | for (const suite of suites) { |
| 320 | if (suite.result?.errors) { |
| 321 | tasks.push(suite) |
| 322 | stats.failures += 1 |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | // If there are no tests, but the file failed to load, we still want to report it as a failure |
| 327 | if (tasks.length === 0 && file.result?.state === 'fail') { |
| 328 | stats.failures = 1 |
| 329 | |
| 330 | tasks.push({ |
| 331 | id: file.id, |
| 332 | type: 'test', |
| 333 | name: file.name, |
| 334 | fullName: file.name, |
| 335 | fullTestName: file.name, |
| 336 | mode: 'run', |
| 337 | result: file.result, |
| 338 | meta: {}, |
| 339 | timeout: 0, |
| 340 | // NOTE: not used in JUnitReporter |
| 341 | context: null as any, |
| 342 | suite: null as any, |
| 343 | file: null as any, |
| 344 | annotations: [], |
| 345 | artifacts: [], |
| 346 | } satisfies Task) |
| 347 | } |
| 348 | |
| 349 | return { |
nothing calls this directly
no test coverage detected