Skip to content
Merged
14 changes: 7 additions & 7 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { TestRunResult } from './types/tests'
import os, { tmpdir } from 'node:os'
import { getTasks, hasFailed, limitConcurrency } from '@vitest/runner/utils'
import { SnapshotManager } from '@vitest/snapshot/manager'
import { deepClone, deepMerge, nanoid, noop, toArray } from '@vitest/utils/helpers'
import { deepClone, deepMerge, nanoid, toArray } from '@vitest/utils/helpers'
import { join, normalize, relative } from 'pathe'
import { isRunnableDevEnvironment } from 'vite'
import { version } from '../../package.json' with { type: 'json' }
Expand Down Expand Up @@ -606,15 +606,15 @@ export class Vitest {
specifications.push(specification)
}

await this._testRun.start(specifications).catch(noop)
await this._testRun.start(specifications)
await this.coverageProvider?.onTestRunStart?.()

for (const file of files) {
await this._reportFileTask(file)
}

this._checkUnhandledErrors(errors)
await this._testRun.end(specifications, errors).catch(noop)
await this._testRun.end(specifications, errors)
await this.initCoverageProvider()
await this.coverageProvider?.mergeReports?.(coverages)

Expand All @@ -635,8 +635,8 @@ export class Vitest {
/** @internal */
public async _reportFileTask(file: File): Promise<void> {
const project = this.getProjectByName(file.projectName || '')
await this._testRun.enqueued(project, file).catch(noop)
await this._testRun.collected(project, [file]).catch(noop)
await this._testRun.enqueued(project, file)
await this._testRun.collected(project, [file])
Comment thread
hi-ogawa marked this conversation as resolved.
Outdated

const logs: UserConsoleLog[] = []

Expand All @@ -649,10 +649,10 @@ export class Vitest {
logs.sort((log1, log2) => log1.time - log2.time)

for (const log of logs) {
await this._testRun.log(log).catch(noop)
await this._testRun.log(log)
}

await this._testRun.updated(packs, events).catch(noop)
await this._testRun.updated(packs, events)
}

async collect(filters?: string[], options?: { staticParse?: boolean; staticParseConcurrency?: number }): Promise<TestRunResult> {
Expand Down
26 changes: 26 additions & 0 deletions test/cli/test/reporters/merge-reports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,32 @@ test('merge reports', async () => {
`)
})

test('throws reporter errors when merging reports', async () => {
await runVitest({
root: './fixtures/reporters/merge-reports',
reporters: ['blob'],
})

let onTestRunEndCalled = false
const { stderr, exitCode } = await runVitest({
root: './fixtures/reporters/merge-reports',
mergeReports: reportsDir,
reporters: [
{
onTestRunStart() {
throw new Error('broken reporter')
},
onTestRunEnd() {
onTestRunEndCalled = true
},
},
],
})
expect(stderr).toContain(`Error: broken reporter`)
expect(onTestRunEndCalled).toBe(false)
expect(exitCode).toBe(1)
})

test('total and merged execution times are shown', async () => {
for (const [_index, name] of ['first.test.ts', 'second.test.ts'].entries()) {
const index = 1 + _index
Expand Down
Loading