Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 30 additions & 27 deletions packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,38 +592,39 @@ export class Vitest {

// schedule the new run
this.runningPromise = (async () => {
if (!this.pool) {
this.pool = createPool(this)
}
try {
if (!this.pool) {
this.pool = createPool(this)
}

const invalidates = Array.from(this.invalidates)
this.invalidates.clear()
this.snapshot.clear()
this.state.clearErrors()
const invalidates = Array.from(this.invalidates)
this.invalidates.clear()
this.snapshot.clear()
this.state.clearErrors()

if (!this.isFirstRun && this.config.coverage.cleanOnRerun) {
await this.coverageProvider?.clean()
}
if (!this.isFirstRun && this.config.coverage.cleanOnRerun) {
await this.coverageProvider?.clean()
}

await this.initializeGlobalSetup(specs)
await this.initializeGlobalSetup(specs)

try {
await this.pool.runTests(specs as WorkspaceSpec[], invalidates)
}
catch (err) {
this.state.catchError(err, 'Unhandled Error')
}
try {
await this.pool.runTests(specs as WorkspaceSpec[], invalidates)
}
catch (err) {
this.state.catchError(err, 'Unhandled Error')
}

const files = this.state.getFiles()
const files = this.state.getFiles()

if (hasFailed(files)) {
process.exitCode = 1
}
if (hasFailed(files)) {
process.exitCode = 1
}

this.cache.results.updateResults(files)
await this.cache.results.writeToCache()
})()
.finally(async () => {
this.cache.results.updateResults(files)
await this.cache.results.writeToCache()
}
finally {
// can be duplicate files if different projects are using the same file
const files = Array.from(new Set(specs.map(spec => spec.moduleId)))
const errors = this.state.getUnhandledErrors()
Expand All @@ -632,7 +633,9 @@ export class Vitest {
this.checkUnhandledErrors(errors)
await this.report('onFinished', this.state.getFiles(files), errors, coverage)
await this.reportCoverage(coverage, allTestsRun)

}
})()
.finally(() => {
this.runningPromise = undefined
this.isFirstRun = false

Expand Down Expand Up @@ -681,7 +684,7 @@ export class Vitest {
process.exitCode = 1
}
})()
.finally(async () => {
.finally(() => {
this.runningPromise = undefined

// all subsequent runs will treat this as a fresh run
Expand Down
Loading