From 8158297f51c2f3a0064dc421cd125412513ee214 Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Tue, 14 May 2024 20:47:28 +0200 Subject: [PATCH] fix!: do not exit process if global setup has failed --- packages/vitest/src/node/workspace.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/vitest/src/node/workspace.ts b/packages/vitest/src/node/workspace.ts index 697c8b5474b6f..17e2f0e95df15 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' @@ -19,7 +18,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 @@ -140,9 +138,8 @@ export class WorkspaceProject { } } catch (e) { - this.logger.error(`\n${c.red(divider(c.bold(c.inverse(' Error during global setup '))))}`) - this.logger.printError(e) - process.exit(1) + process.exitCode = 1 + throw e } } @@ -154,9 +151,8 @@ export class WorkspaceProject { await globalSetupFile.teardown?.() } catch (error) { - this.logger.error(`error during global teardown of ${globalSetupFile.file}`, error) - this.logger.printError(error) process.exitCode = 1 + throw error } } }