* Merge reports from multiple runs located in the specified directory (value from `--merge-reports` if not specified).
(directory?: string)
| 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. |
no test coverage detected