Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed May 31, 2024
1 parent 6cb93b5 commit c0ff3c5
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions packages/vitest/src/node/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,34 +137,21 @@ export class WorkspaceProject {

this._globalSetups = await loadGlobalSetupFiles(this.runner, this.config.globalSetup)

try {
for (const globalSetupFile of this._globalSetups) {
const teardown = await globalSetupFile.setup?.({ provide: this.provide, config: this.config })
if (teardown == null || !!globalSetupFile.teardown)
continue
if (typeof teardown !== 'function')
throw new Error(`invalid return value in globalSetup file ${globalSetupFile.file}. Must return a function`)
globalSetupFile.teardown = teardown
}
}
catch (e) {
process.exitCode = 1
throw e
for (const globalSetupFile of this._globalSetups) {
const teardown = await globalSetupFile.setup?.({ provide: this.provide, config: this.config })
if (teardown == null || !!globalSetupFile.teardown)
continue
if (typeof teardown !== 'function')
throw new Error(`invalid return value in globalSetup file ${globalSetupFile.file}. Must return a function`)
globalSetupFile.teardown = teardown
}
}

async teardownGlobalSetup() {
if (!this._globalSetups)
return
for (const globalSetupFile of [...this._globalSetups].reverse()) {
try {
await globalSetupFile.teardown?.()
}
catch (error) {
process.exitCode = 1
throw error
}
}
for (const globalSetupFile of [...this._globalSetups].reverse())
await globalSetupFile.teardown?.()
}

get logger() {
Expand Down

0 comments on commit c0ff3c5

Please sign in to comment.