MCPcopy
hub / github.com/vitest-dev/vitest / mergeReports

Method mergeReports

packages/vitest/src/node/core.ts:609–646  ·  view source on GitHub ↗

* Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).

(directory?: string)

Source from the content-addressed store, hash-verified

607 * Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
608 */
609 public async mergeReports(directory?: string): Promise<TestRunResult> {
610 return this._traces.$('vitest.merge_reports', async () => {
611 if (this.reporters.some(r => r instanceof BlobReporter)) {
612 throw new Error('Cannot merge reports when `--reporter=blob` is used. Remove blob reporter from the config first.')
613 }
614
615 const { files, errors, coverages, executionTimes } = await readBlobs(this.version, directory || this.config.mergeReports, this.projects)
616 this.state.blobs = { files, errors, coverages, executionTimes }
617
618 await this.report('onInit', this)
619
620 const specifications: TestSpecification[] = []
621 for (const file of files) {
622 const project = this.getProjectByName(file.projectName || '')
623 const specification = project.createSpecification(file.filepath, undefined, file.pool)
624 specifications.push(specification)
625 }
626
627 await this._testRun.start(specifications)
628 await this.coverageProvider?.onTestRunStart?.()
629
630 for (const file of files) {
631 await this._reportFileTask(file)
632 }
633
634 // append errors thrown during reporter event replay during merge reports
635 const unhandledErrors = [...errors, ...this.state.getUnhandledErrors()]
636 this._checkUnhandledErrors(unhandledErrors)
637 await this._testRun.end(specifications, unhandledErrors)
638 await this.initCoverageProvider()
639 await this.coverageProvider?.mergeReports?.(coverages)
640
641 return {
642 testModules: this.state.getTestModules(),
643 unhandledErrors: this.state.getUnhandledErrors(),
644 }
645 })
646 }
647
648 /**
649 * Returns the seed, if tests are running in a random order.

Callers 1

startVitestFunction · 0.45

Calls 13

reportMethod · 0.95
getProjectByNameMethod · 0.95
_reportFileTaskMethod · 0.95
_checkUnhandledErrorsMethod · 0.95
initCoverageProviderMethod · 0.95
readBlobsFunction · 0.90
$Method · 0.80
createSpecificationMethod · 0.80
getUnhandledErrorsMethod · 0.80
endMethod · 0.80
getTestModulesMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected