diff --git a/packages/vitest/src/node/workspace.ts b/packages/vitest/src/node/workspace.ts index 6d76890c052d..4b4500d37f41 100644 --- a/packages/vitest/src/node/workspace.ts +++ b/packages/vitest/src/node/workspace.ts @@ -7,7 +7,6 @@ import { dirname, isAbsolute, join, relative, resolve, toNamespacedPath } from ' import type { TransformResult, ViteDevServer, InlineConfig as ViteInlineConfig } from 'vite' import { ViteNodeRunner } from 'vite-node/client' import { ViteNodeServer } from 'vite-node/server' -import c from 'picocolors' import { createBrowserServer } from '../integrations/browser/server' import type { ProvidedContext, ResolvedConfig, UserConfig, UserWorkspaceConfig, Vitest } from '../types' import type { Typechecker } from '../typecheck/typechecker' @@ -21,7 +20,6 @@ import { WorkspaceVitestPlugin } from './plugins/workspace' import { createViteServer } from './vite' import type { GlobalSetupFile } from './globalSetup' import { loadGlobalSetupFiles } from './globalSetup' -import { divider } from './reporters/renderers/utils' interface InitializeProjectOptions extends UserWorkspaceConfig { workspaceConfigPath: string @@ -139,36 +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) { - this.logger.error(`\n${c.red(divider(c.bold(c.inverse(' Error during global setup '))))}`) - this.logger.printError(e) - process.exit(1) + 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) { - this.logger.error(`error during global teardown of ${globalSetupFile.file}`, error) - this.logger.printError(error) - process.exitCode = 1 - } - } + for (const globalSetupFile of [...this._globalSetups].reverse()) + await globalSetupFile.teardown?.() } get logger() {