vitest 0.34.3 → 0.34.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { startTests } from '@vitest/runner';
2
- import { R as ResolvedConfig, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule } from './reporters-2ff87305.js';
2
+ import { R as ResolvedConfig, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule } from './reporters-cb94c88b.js';
3
3
  import 'vite';
4
4
  import 'vite-node';
5
5
  import '@vitest/snapshot';
package/dist/browser.js CHANGED
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals)
16
- (await import('./chunk-integrations-globals.7f4b17bf.js')).registerApiGlobally();
16
+ (await import('./chunk-integrations-globals.09bbbed7.js')).registerApiGlobally();
17
17
  }
18
18
  function setupDefines(defines) {
19
19
  for (const key in defines)
package/dist/child.js CHANGED
@@ -2,7 +2,7 @@ import { performance } from 'node:perf_hooks';
2
2
  import v8 from 'node:v8';
3
3
  import { c as createBirpc } from './vendor-index.b271ebe4.js';
4
4
  import { parseRegexp } from '@vitest/utils';
5
- import { l as loadEnvironment } from './vendor-environments.8eb4d407.js';
5
+ import { l as loadEnvironment } from './vendor-environments.c9c96bf7.js';
6
6
  import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.a63e187f.js';
7
7
  import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
8
8
  import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
@@ -4555,18 +4555,18 @@ function setup(vitestOrWorkspace, server) {
4555
4555
  },
4556
4556
  async saveTestFile(id, content) {
4557
4557
  if (!ctx.state.filesMap.has(id) || !existsSync(id))
4558
- return;
4558
+ throw new Error(`Test file "${id}" was not registered, so it cannot be updated using the API.`);
4559
4559
  return promises.writeFile(id, content, "utf-8");
4560
4560
  },
4561
4561
  async saveSnapshotFile(id, content) {
4562
4562
  if (!ctx.snapshot.resolvedPaths.has(id))
4563
- return;
4563
+ throw new Error(`Snapshot file "${id}" does not exist.`);
4564
4564
  await promises.mkdir(dirname(id), { recursive: true });
4565
4565
  return promises.writeFile(id, content, "utf-8");
4566
4566
  },
4567
4567
  async removeSnapshotFile(id) {
4568
4568
  if (!ctx.snapshot.resolvedPaths.has(id) || !existsSync(id))
4569
- return;
4569
+ throw new Error(`Snapshot file "${id}" does not exist.`);
4570
4570
  return promises.unlink(id);
4571
4571
  },
4572
4572
  snapshotSaved(snapshot) {
@@ -4,7 +4,7 @@ import { g as getDefaultExportFromCjs } from './vendor-_commonjsHelpers.7d1333e8
4
4
  import require$$2 from 'util';
5
5
  import require$$0$1 from 'child_process';
6
6
  import { p as pathKeyExports, s as signalExitExports, m as mergeStream$1, g as getStreamExports, c as crossSpawnExports } from './vendor-index.1f85e5f1.js';
7
- import { o as onetimeExports } from './vendor-node.5ce5f335.js';
7
+ import { o as onetimeExports } from './vendor-node.b14cb9ad.js';
8
8
  import require$$0 from 'os';
9
9
  import 'node:buffer';
10
10
  import 'node:path';
@@ -51,7 +51,7 @@ import 'acorn';
51
51
  import 'acorn-walk';
52
52
  import 'magic-string';
53
53
  import 'strip-literal';
54
- import './vendor-environments.8eb4d407.js';
54
+ import './vendor-environments.c9c96bf7.js';
55
55
  import './vendor-index.0b5b3600.js';
56
56
  import 'node:assert';
57
57
  import 'node:console';
@@ -1,7 +1,7 @@
1
1
  import { g as globalApis } from './vendor-constants.538d9b49.js';
2
- import { i as index } from './vendor-index.7178e7a2.js';
2
+ import { i as index } from './vendor-index.e951dd92.js';
3
3
  import '@vitest/runner';
4
- import './vendor-vi.597d9e06.js';
4
+ import './vendor-vi.befc11a6.js';
5
5
  import '@vitest/runner/utils';
6
6
  import '@vitest/utils';
7
7
  import './vendor-index.29282562.js';
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest } from './vendor-node.5ce5f335.js';
4
+ import { v as version, s as startVitest } from './vendor-node.b14cb9ad.js';
5
5
  import './vendor-index.29282562.js';
6
6
  import { d as divider } from './vendor-reporters.f6975b8d.js';
7
7
  import { t as toArray } from './vendor-base.9c08bbd0.js';
@@ -48,7 +48,7 @@ import 'acorn-walk';
48
48
  import '@vitest/runner/utils';
49
49
  import 'magic-string';
50
50
  import 'strip-literal';
51
- import './vendor-environments.8eb4d407.js';
51
+ import './vendor-environments.c9c96bf7.js';
52
52
  import './vendor-index.0b5b3600.js';
53
53
  import 'node:module';
54
54
  import 'node:assert';
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
- import { c as ResolvedCoverageOptions, U as UserConfig, d as CoverageV8Options, P as ProjectConfig } from './reporters-2ff87305.js';
3
+ import { c as ResolvedCoverageOptions, U as UserConfig, d as CoverageV8Options, P as ProjectConfig } from './reporters-cb94c88b.js';
4
4
  import '@vitest/runner';
5
5
  import 'vite-node';
6
6
  import '@vitest/snapshot';
@@ -1,4 +1,4 @@
1
- import { B as BaseCoverageOptions, c as ResolvedCoverageOptions } from './reporters-2ff87305.js';
1
+ import { B as BaseCoverageOptions, c as ResolvedCoverageOptions } from './reporters-cb94c88b.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/entry-vm.js CHANGED
@@ -6,7 +6,7 @@ import { setupColors, createColors } from '@vitest/utils';
6
6
  import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.9378c9a4.js';
7
7
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js';
8
8
  import { g as getWorkerState } from './vendor-global.97e4527c.js';
9
- import { i as index } from './vendor-index.7178e7a2.js';
9
+ import { i as index } from './vendor-index.e951dd92.js';
10
10
  import { setupCommonEnv } from './browser.js';
11
11
  import 'chai';
12
12
  import '@vitest/snapshot/environment';
@@ -14,7 +14,7 @@ import 'pathe';
14
14
  import './vendor-paths.84fc7a99.js';
15
15
  import 'node:url';
16
16
  import './vendor-rpc.cbd8e972.js';
17
- import './vendor-vi.597d9e06.js';
17
+ import './vendor-vi.befc11a6.js';
18
18
  import '@vitest/runner/utils';
19
19
  import './vendor-index.29282562.js';
20
20
  import 'std-env';
package/dist/entry.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import './vendor-index.29282562.js';
4
- import { d as globalExpect, r as resetModules, v as vi } from './vendor-vi.597d9e06.js';
4
+ import { d as globalExpect, r as resetModules, v as vi } from './vendor-vi.befc11a6.js';
5
5
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js';
6
6
  import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.9378c9a4.js';
7
7
  import { createRequire } from 'node:module';
8
8
  import { isatty } from 'node:tty';
9
9
  import { installSourcemapsSupport } from 'vite-node/source-map';
10
10
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
11
- import { i as index } from './vendor-index.7178e7a2.js';
11
+ import { i as index } from './vendor-index.e951dd92.js';
12
12
  import { setupCommonEnv } from './browser.js';
13
13
  import { g as getWorkerState } from './vendor-global.97e4527c.js';
14
14
  import 'pathe';
@@ -50,6 +50,9 @@ async function setupGlobalEnv(config, { environment }) {
50
50
  _require.extensions[".scss"] = () => ({});
51
51
  _require.extensions[".sass"] = () => ({});
52
52
  _require.extensions[".less"] = () => ({});
53
+ process.env.SSR = "";
54
+ } else {
55
+ process.env.SSR = "1";
53
56
  }
54
57
  installSourcemapsSupport({
55
58
  getSourceMap: (source) => state.moduleCache.getSourceMap(source)
@@ -1,4 +1,4 @@
1
- import { E as Environment } from './reporters-2ff87305.js';
1
+ import { E as Environment } from './reporters-cb94c88b.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,4 +1,4 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.8eb4d407.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.c9c96bf7.js';
2
2
  import 'node:url';
3
3
  import 'pathe';
4
4
  import './vendor-index.0b5b3600.js';
package/dist/execute.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import vm from 'node:vm';
2
2
  import { ViteNodeRunner } from 'vite-node/client';
3
3
  import { ViteNodeRunnerOptions } from 'vite-node';
4
- import { h as PendingSuiteMock, M as MockFactory, i as WorkerGlobalState, j as MockMap, k as RuntimeRPC } from './reporters-2ff87305.js';
4
+ import { h as PendingSuiteMock, M as MockFactory, i as WorkerGlobalState, j as MockMap, k as RuntimeRPC } from './reporters-cb94c88b.js';
5
5
  import 'vite';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/snapshot';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Test, File, TaskResultPack, CancelReason } from '@vitest/runner';
2
2
  export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- import { l as BenchmarkAPI, F as FakeTimerInstallOpts, m as MockFactoryWithHelper, n as RuntimeConfig, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-2ff87305.js';
4
- export { I as ApiConfig, a4 as ArgumentsType, a3 as Arrayable, a1 as Awaitable, B as BaseCoverageOptions, ai as BenchFunction, ag as Benchmark, ah as BenchmarkResult, af as BenchmarkUserOptions, y as BuiltinEnvironment, G as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a6 as Constructable, x as Context, Z as ContextRPC, X as ContextTestEnvironment, ad as CoverageIstanbulOptions, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule, ac as CoverageReporter, d as CoverageV8Options, ae as CustomProviderOptions, L as DepsOptimizationOptions, E as Environment, K as EnvironmentOptions, a8 as EnvironmentReturn, H as HappyDOMOptions, O as InlineConfig, J as JSDOMOptions, a7 as ModuleCache, a5 as MutableArray, a2 as Nullable, aa as OnServerRestartHandler, P as ProjectConfig, r as RawErrsMap, ab as ReportContext, $ as ResolveIdFunction, c as ResolvedCoverageOptions, Y as ResolvedTestEnvironment, w as RootAndTarget, S as RunnerRPC, k as RuntimeRPC, N as TransformModePatterns, t as TscErrorInfo, Q as TypecheckConfig, U as UserConfig, e as Vitest, z as VitestEnvironment, D as VitestPool, V as VitestRunMode, a9 as VmEnvironmentReturn, _ as WorkerContext, i as WorkerGlobalState, a0 as WorkerRPC } from './reporters-2ff87305.js';
3
+ import { l as BenchmarkAPI, F as FakeTimerInstallOpts, m as MockFactoryWithHelper, n as RuntimeConfig, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-cb94c88b.js';
4
+ export { I as ApiConfig, a4 as ArgumentsType, a3 as Arrayable, a1 as Awaitable, B as BaseCoverageOptions, ai as BenchFunction, ag as Benchmark, ah as BenchmarkResult, af as BenchmarkUserOptions, y as BuiltinEnvironment, G as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a6 as Constructable, x as Context, Z as ContextRPC, X as ContextTestEnvironment, ad as CoverageIstanbulOptions, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule, ac as CoverageReporter, d as CoverageV8Options, ae as CustomProviderOptions, L as DepsOptimizationOptions, E as Environment, K as EnvironmentOptions, a8 as EnvironmentReturn, H as HappyDOMOptions, O as InlineConfig, J as JSDOMOptions, a7 as ModuleCache, a5 as MutableArray, a2 as Nullable, aa as OnServerRestartHandler, P as ProjectConfig, r as RawErrsMap, ab as ReportContext, $ as ResolveIdFunction, c as ResolvedCoverageOptions, Y as ResolvedTestEnvironment, w as RootAndTarget, S as RunnerRPC, k as RuntimeRPC, N as TransformModePatterns, t as TscErrorInfo, Q as TypecheckConfig, U as UserConfig, e as Vitest, z as VitestEnvironment, D as VitestPool, V as VitestRunMode, a9 as VmEnvironmentReturn, _ as WorkerContext, i as WorkerGlobalState, a0 as WorkerRPC } from './reporters-cb94c88b.js';
5
5
  import { ExpectStatic } from '@vitest/expect';
6
6
  export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
7
7
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
@@ -351,7 +351,7 @@ interface VitestUtils {
351
351
  declare const vitest: VitestUtils;
352
352
  declare const vi: VitestUtils;
353
353
 
354
- declare function getRunningMode(): "run" | "watch";
354
+ declare function getRunningMode(): "watch" | "run";
355
355
  declare function isWatchMode(): boolean;
356
356
 
357
357
  interface TransformResultWithSource extends TransformResult {
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.597d9e06.js';
2
+ export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.befc11a6.js';
3
3
  export { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js';
4
- import { d as dist } from './vendor-index.7178e7a2.js';
5
- export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.7178e7a2.js';
4
+ import { d as dist } from './vendor-index.e951dd92.js';
5
+ export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.e951dd92.js';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VitestRunMode, U as UserConfig, e as Vitest, T as TestSequencer, W as WorkspaceSpec } from './reporters-2ff87305.js';
2
- export { g as TestSequencerConstructor, f as VitestWorkspace, s as startVitest } from './reporters-2ff87305.js';
1
+ import { V as VitestRunMode, U as UserConfig, e as Vitest, T as TestSequencer, W as WorkspaceSpec } from './reporters-cb94c88b.js';
2
+ export { g as TestSequencerConstructor, f as VitestWorkspace, s as startVitest } from './reporters-cb94c88b.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import '@vitest/runner';
5
5
  import 'vite-node';
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.5ce5f335.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.b14cb9ad.js';
2
2
  import 'pathe';
3
3
  import 'vite';
4
4
  import 'node:path';
@@ -51,7 +51,7 @@ import 'acorn';
51
51
  import 'acorn-walk';
52
52
  import 'magic-string';
53
53
  import 'strip-literal';
54
- import './vendor-environments.8eb4d407.js';
54
+ import './vendor-environments.c9c96bf7.js';
55
55
  import './vendor-index.0b5b3600.js';
56
56
  import 'node:assert';
57
57
  import 'node:console';
@@ -1,5 +1,5 @@
1
1
  import * as vite from 'vite';
2
- import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, CommonServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
2
+ import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
3
3
  import * as _vitest_runner from '@vitest/runner';
4
4
  import { File, Test as Test$1, Suite, TaskResultPack, Task, CancelReason, TaskCustom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
5
5
  import { RawSourceMap, FetchResult, ViteNodeResolveId, ModuleCacheMap, ViteNodeServerOptions } from 'vite-node';
@@ -447,10 +447,6 @@ declare class Typechecker {
447
447
  getTestPacks(): TaskResultPack[];
448
448
  }
449
449
 
450
- interface InitializeServerOptions {
451
- server?: ViteNodeServer;
452
- runner?: ViteNodeRunner;
453
- }
454
450
  declare class WorkspaceProject {
455
451
  path: string | number;
456
452
  ctx: Vitest;
@@ -478,8 +474,9 @@ declare class WorkspaceProject {
478
474
  isTargetFile(id: string, source?: string): Promise<boolean>;
479
475
  isInSourceTestFile(code: string): boolean;
480
476
  filterFiles(testFiles: string[], filters: string[] | undefined, dir: string): string[];
481
- initBrowserServer(options: UserConfig): Promise<void>;
482
- setServer(options: UserConfig, server: ViteDevServer, params?: InitializeServerOptions): Promise<void>;
477
+ initBrowserServer(configFile: string | undefined): Promise<void>;
478
+ static createCoreProject(ctx: Vitest): Promise<WorkspaceProject>;
479
+ setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
483
480
  report<T extends keyof Reporter>(name: T, ...args: ArgumentsType$1<Reporter[T]>): Promise<void>;
484
481
  typecheck(filters?: string[]): Promise<void>;
485
482
  isBrowserEnabled(): boolean | 0;
@@ -709,7 +706,7 @@ declare class VitestCache {
709
706
  getFileStats(key: string): {
710
707
  size: number;
711
708
  } | undefined;
712
- static resolveCacheDir(root: string, dir: string | undefined): string;
709
+ static resolveCacheDir(root: string, dir: string | undefined, projectName: string | undefined): string;
713
710
  static clearCache(options: CliOptions): Promise<{
714
711
  dir: string;
715
712
  cleared: boolean;
@@ -747,7 +744,7 @@ declare class Vitest {
747
744
  private _onSetServer;
748
745
  private _onCancelListeners;
749
746
  setServer(options: UserConfig, server: ViteDevServer, cliOptions: UserConfig): Promise<void>;
750
- private createCoreWorkspace;
747
+ private createCoreProject;
751
748
  getCoreWorkspaceProject(): WorkspaceProject | null;
752
749
  getProjectByTaskId(taskId: string): WorkspaceProject;
753
750
  private resolveWorkspace;
@@ -1533,7 +1530,7 @@ type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';
1533
1530
  type VitestEnvironment = BuiltinEnvironment | (string & Record<never, never>);
1534
1531
  type VitestPool = 'browser' | 'threads' | 'child_process' | 'experimentalVmThreads';
1535
1532
  type CSSModuleScopeStrategy = 'stable' | 'scoped' | 'non-scoped';
1536
- type ApiConfig = Pick<CommonServerOptions, 'port' | 'strictPort' | 'host'>;
1533
+ type ApiConfig = Pick<ServerOptions, 'port' | 'strictPort' | 'host' | 'middlewareMode'>;
1537
1534
 
1538
1535
  interface EnvironmentOptions {
1539
1536
  /**
@@ -1981,7 +1978,7 @@ interface InlineConfig {
1981
1978
  */
1982
1979
  uiBase?: string;
1983
1980
  /**
1984
- * Determine the transform method for all modules inported inside a test that matches the glob pattern.
1981
+ * Determine the transform method for all modules imported inside a test that matches the glob pattern.
1985
1982
  */
1986
1983
  testTransformMode?: TransformModePatterns;
1987
1984
  /**
@@ -1,4 +1,4 @@
1
- export { as as BaseReporter, ak as BasicReporter, aw as BenchmarkBuiltinReporters, av as BenchmarkReportsMap, au as BuiltinReporters, aj as DefaultReporter, al as DotReporter, ar as HangingProcessReporter, ap as JUnitReporter, am as JsonReporter, q as Reporter, at as ReportersMap, aq as TapFlatReporter, ao as TapReporter, an as VerboseReporter } from './reporters-2ff87305.js';
1
+ export { as as BaseReporter, ak as BasicReporter, aw as BenchmarkBuiltinReporters, av as BenchmarkReportsMap, au as BuiltinReporters, aj as DefaultReporter, al as DotReporter, ar as HangingProcessReporter, ap as JUnitReporter, am as JsonReporter, q as Reporter, at as ReportersMap, aq as TapFlatReporter, ao as TapReporter, an as VerboseReporter } from './reporters-cb94c88b.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-2ff87305.js';
2
+ import { R as ResolvedConfig } from './reporters-cb94c88b.js';
3
3
  import 'vite';
4
4
  import 'vite-node';
5
5
  import '@vitest/snapshot';
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.597d9e06.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.befc11a6.js';
3
3
  import './vendor-index.29282562.js';
4
4
  import { a as rpc } from './vendor-rpc.cbd8e972.js';
5
5
  import { g as getFullName } from './vendor-tasks.f9d75aed.js';
@@ -558,6 +558,7 @@ var happy = {
558
558
  const { Window, GlobalWindow } = await importModule("happy-dom");
559
559
  const win = new (GlobalWindow || Window)({
560
560
  ...happyDOM,
561
+ console: console && global.console ? global.console : void 0,
561
562
  url: happyDOM.url || "http://localhost:3000"
562
563
  });
563
564
  const { keys, originals } = populateGlobal(global, win, { bindFunctions: true });
@@ -1,5 +1,5 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- import { e as bench, c as createExpect, d as globalExpect, v as vi, f as vitest } from './vendor-vi.597d9e06.js';
2
+ import { e as bench, c as createExpect, d as globalExpect, v as vi, f as vitest } from './vendor-vi.befc11a6.js';
3
3
  import { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js';
4
4
  import * as chai from 'chai';
5
5
  import { assert, should } from 'chai';
@@ -31,7 +31,7 @@ import { createDefer, shuffle, inspect, positionToOffset, lineSplitRE, notNullis
31
31
  import { isPackageExists, resolveModule } from 'local-pkg';
32
32
  import { isCI } from 'std-env';
33
33
  import { R as ReportersMap, B as BenchmarkReportsMap, s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as divider, F as F_POINTER, e as cliTruncate } from './vendor-reporters.f6975b8d.js';
34
- import { createHash } from 'node:crypto';
34
+ import crypto, { createHash } from 'node:crypto';
35
35
  import { o as onExit, e as execa } from './vendor-index.1f85e5f1.js';
36
36
  import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
37
37
  import { writeFile, rm } from 'node:fs/promises';
@@ -41,7 +41,7 @@ import { ancestor, simple, findNodeAround } from 'acorn-walk';
41
41
  import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
42
42
  import MagicString from 'magic-string';
43
43
  import { stripLiteral } from 'strip-literal';
44
- import { g as getEnvPackageName } from './vendor-environments.8eb4d407.js';
44
+ import { g as getEnvPackageName } from './vendor-environments.c9c96bf7.js';
45
45
  import readline from 'node:readline';
46
46
  import require$$0$2 from 'readline';
47
47
 
@@ -60,7 +60,7 @@ function _mergeNamespaces(n, m) {
60
60
  return Object.freeze(n);
61
61
  }
62
62
 
63
- var version$1 = "0.34.3";
63
+ var version$1 = "0.34.4";
64
64
 
65
65
  const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
66
66
  async function ensurePackageInstalled(dependency, root) {
@@ -79,7 +79,7 @@ async function ensurePackageInstalled(dependency, root) {
79
79
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
80
80
  });
81
81
  if (install) {
82
- await (await import('./chunk-install-pkg.a036014e.js')).installPackage(dependency, { dev: true });
82
+ await (await import('./chunk-install-pkg.b2bdbadc.js')).installPackage(dependency, { dev: true });
83
83
  process.stderr.write(c.yellow(`
84
84
  Package ${dependency} installed, re-run the command to start.
85
85
  `));
@@ -8130,18 +8130,20 @@ class VitestCache {
8130
8130
  getFileStats(key) {
8131
8131
  return this.stats.getStats(key);
8132
8132
  }
8133
- static resolveCacheDir(root, dir) {
8134
- return resolve(root, slash$1(dir || "node_modules/.vitest"));
8133
+ static resolveCacheDir(root, dir, projectName) {
8134
+ const baseDir = slash$1(dir || "node_modules/.vitest");
8135
+ return projectName ? resolve(root, baseDir, crypto.createHash("md5").update(projectName, "utf-8").digest("hex")) : resolve(root, baseDir);
8135
8136
  }
8136
8137
  static async clearCache(options) {
8137
- var _a, _b;
8138
+ var _a, _b, _c;
8138
8139
  const root = resolve(options.root || process.cwd());
8139
8140
  const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
8140
8141
  const config = configPath ? (_a = await loadConfigFromFile({ command: "serve", mode: "test" }, configPath)) == null ? void 0 : _a.config : void 0;
8141
8142
  const cache = (_b = config == null ? void 0 : config.test) == null ? void 0 : _b.cache;
8143
+ const projectName = (_c = config == null ? void 0 : config.test) == null ? void 0 : _c.name;
8142
8144
  if (cache === false)
8143
8145
  throw new Error("Cache is disabled");
8144
- const cachePath = VitestCache.resolveCacheDir(root, cache == null ? void 0 : cache.dir);
8146
+ const cachePath = VitestCache.resolveCacheDir(root, cache == null ? void 0 : cache.dir, projectName);
8145
8147
  let cleared = false;
8146
8148
  if (fs$8.existsSync(cachePath)) {
8147
8149
  fs$8.rmSync(cachePath, { recursive: true, force: true });
@@ -8232,8 +8234,10 @@ function resolveApiServerConfig(options) {
8232
8234
  }
8233
8235
  }
8234
8236
  if (api) {
8235
- if (!api.port)
8237
+ if (!api.port && !api.middlewareMode)
8236
8238
  api.port = defaultPort;
8239
+ } else {
8240
+ api = { middlewareMode: true };
8237
8241
  }
8238
8242
  return api;
8239
8243
  }
@@ -8422,7 +8426,7 @@ function resolveConfig(mode, options, viteConfig) {
8422
8426
  }
8423
8427
  resolved.cache ?? (resolved.cache = { dir: "" });
8424
8428
  if (resolved.cache)
8425
- resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir);
8429
+ resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir, resolved.name);
8426
8430
  resolved.sequence ?? (resolved.sequence = {});
8427
8431
  if (!((_q = resolved.sequence) == null ? void 0 : _q.sequencer)) {
8428
8432
  resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
@@ -9007,7 +9011,7 @@ createLogUpdate(process$1.stdout);
9007
9011
 
9008
9012
  createLogUpdate(process$1.stderr);
9009
9013
 
9010
- var version = "0.34.3";
9014
+ var version = "0.34.4";
9011
9015
 
9012
9016
  const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d$1(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d$1(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
9013
9017
 
@@ -9783,7 +9787,7 @@ No ${config.mode} files found, exiting with code 1`));
9783
9787
  }
9784
9788
  }
9785
9789
  printBanner() {
9786
- var _a, _b;
9790
+ var _a, _b, _c;
9787
9791
  this.log();
9788
9792
  const versionTest = this.ctx.config.watch ? c.blue(`v${version}`) : c.cyan(`v${version}`);
9789
9793
  const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
@@ -9800,8 +9804,8 @@ No ${config.mode} files found, exiting with code 1`));
9800
9804
  });
9801
9805
  if (this.ctx.config.ui)
9802
9806
  this.log(c.dim(c.green(` UI started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
9803
- else if (this.ctx.config.api)
9804
- this.log(c.dim(c.green(` API started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${c.bold(`${this.ctx.config.api.port}`)}`)));
9807
+ else if ((_b = this.ctx.config.api) == null ? void 0 : _b.port)
9808
+ this.log(c.dim(c.green(` API started at http://${((_c = this.ctx.config.api) == null ? void 0 : _c.host) || "localhost"}:${c.bold(`${this.ctx.config.api.port}`)}`)));
9805
9809
  if (this.ctx.coverageProvider)
9806
9810
  this.log(c.dim(" Coverage enabled with ") + c.yellow(this.ctx.coverageProvider.name));
9807
9811
  this.log();
@@ -10001,7 +10005,8 @@ function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
10001
10005
  entries: []
10002
10006
  };
10003
10007
  } else {
10004
- const cacheDir = testConfig.cache !== false ? (_a = testConfig.cache) == null ? void 0 : _a.dir : null;
10008
+ const root = testConfig.root ?? process.cwd();
10009
+ const cacheDir = testConfig.cache !== false ? (_a = testConfig.cache) == null ? void 0 : _a.dir : void 0;
10005
10010
  const currentInclude = testOptions.include || (viteOptions == null ? void 0 : viteOptions.include) || [];
10006
10011
  const exclude = [
10007
10012
  "vitest",
@@ -10012,7 +10017,7 @@ function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
10012
10017
  const runtime = currentInclude.filter((n) => n.endsWith("jsx-dev-runtime"));
10013
10018
  exclude.push(...runtime);
10014
10019
  const include = (testOptions.include || (viteOptions == null ? void 0 : viteOptions.include) || []).filter((n) => !exclude.includes(n));
10015
- newConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
10020
+ newConfig.cacheDir = cacheDir ?? VitestCache.resolveCacheDir(root, cacheDir, testConfig.name);
10016
10021
  newConfig.optimizeDeps = {
10017
10022
  ...viteOptions,
10018
10023
  ...testOptions,
@@ -10071,10 +10076,10 @@ function resolveFsAllow(projectRoot, rootConfigFile) {
10071
10076
  return [dirname(rootConfigFile), searchForWorkspaceRoot(projectRoot)];
10072
10077
  }
10073
10078
 
10074
- async function createBrowserServer(project, options) {
10079
+ async function createBrowserServer(project, configFile) {
10075
10080
  const root = project.config.root;
10076
10081
  await ensurePackageInstalled("@vitest/browser", root);
10077
- const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
10082
+ const configPath = typeof configFile === "string" ? configFile : false;
10078
10083
  const server = await createServer({
10079
10084
  logLevel: "error",
10080
10085
  mode: project.config.mode,
@@ -10097,6 +10102,7 @@ async function createBrowserServer(project, options) {
10097
10102
  const server2 = resolveApiServerConfig(((_a = config.test) == null ? void 0 : _a.browser) || {}) || {
10098
10103
  port: defaultBrowserPort
10099
10104
  };
10105
+ server2.middlewareMode = false;
10100
10106
  config.server = server2;
10101
10107
  (_b = config.server).fs ?? (_b.fs = {});
10102
10108
  config.server.fs.allow = config.server.fs.allow || [];
@@ -10118,7 +10124,7 @@ async function createBrowserServer(project, options) {
10118
10124
  });
10119
10125
  await server.listen();
10120
10126
  await server.watcher.close();
10121
- (await import('./chunk-api-setup.3b016b1c.js')).setup(project, server);
10127
+ (await import('./chunk-api-setup.d65b007d.js')).setup(project, server);
10122
10128
  return server;
10123
10129
  }
10124
10130
 
@@ -10452,9 +10458,8 @@ function VitestOptimizer() {
10452
10458
  const ssrOptimizer = resolveOptimizerConfig((_d = (_c = testConfig.deps) == null ? void 0 : _c.optimizer) == null ? void 0 : _d.ssr, (_e = viteConfig.ssr) == null ? void 0 : _e.optimizeDeps, testConfig);
10453
10459
  viteConfig.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || viteConfig.cacheDir;
10454
10460
  viteConfig.optimizeDeps = webOptimizer.optimizeDeps;
10455
- viteConfig.ssr = {
10456
- optimizeDeps: ssrOptimizer.optimizeDeps
10457
- };
10461
+ viteConfig.ssr ?? (viteConfig.ssr = {});
10462
+ viteConfig.ssr.optimizeDeps = ssrOptimizer.optimizeDeps;
10458
10463
  }
10459
10464
  }
10460
10465
  };
@@ -10508,6 +10513,7 @@ function WorkspaceVitestPlugin(project, options) {
10508
10513
  open: false,
10509
10514
  hmr: false,
10510
10515
  preTransformRequests: false,
10516
+ middlewareMode: true,
10511
10517
  fs: {
10512
10518
  allow: resolveFsAllow(
10513
10519
  project.ctx.config.root,
@@ -10561,8 +10567,22 @@ function WorkspaceVitestPlugin(project, options) {
10561
10567
  ];
10562
10568
  }
10563
10569
 
10570
+ async function createViteServer(inlineConfig) {
10571
+ const error = console.error;
10572
+ console.error = (...args) => {
10573
+ if (typeof args[0] === "string" && args[0].includes("WebSocket server error:"))
10574
+ return;
10575
+ error(...args);
10576
+ };
10577
+ const server = await createServer({
10578
+ logLevel: "error",
10579
+ ...inlineConfig
10580
+ });
10581
+ console.error = error;
10582
+ return server;
10583
+ }
10584
+
10564
10585
  async function initializeProject(workspacePath, ctx, options) {
10565
- var _a, _b, _c, _d, _e, _f, _g;
10566
10586
  const project = new WorkspaceProject(workspacePath, ctx);
10567
10587
  const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
10568
10588
  const root = options.root || (typeof workspacePath === "number" ? void 0 : dirname(workspacePath));
@@ -10578,11 +10598,7 @@ async function initializeProject(workspacePath, ctx, options) {
10578
10598
  WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
10579
10599
  ]
10580
10600
  };
10581
- const server = await createServer(config);
10582
- if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = project.config.deps) == null ? void 0 : _b.optimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = project.config.deps) == null ? void 0 : _e.optimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
10583
- await server.listen();
10584
- else
10585
- await server.pluginContainer.buildStart({});
10601
+ await createViteServer(config);
10586
10602
  return project;
10587
10603
  }
10588
10604
  class WorkspaceProject {
@@ -10686,19 +10702,28 @@ class WorkspaceProject {
10686
10702
  }
10687
10703
  return testFiles;
10688
10704
  }
10689
- async initBrowserServer(options) {
10705
+ async initBrowserServer(configFile) {
10690
10706
  var _a;
10691
10707
  if (!this.isBrowserEnabled())
10692
10708
  return;
10693
10709
  await ((_a = this.browser) == null ? void 0 : _a.close());
10694
- this.browser = await createBrowserServer(this, options);
10695
- }
10696
- async setServer(options, server, params = {}) {
10710
+ this.browser = await createBrowserServer(this, configFile);
10711
+ }
10712
+ static async createCoreProject(ctx) {
10713
+ const project = new WorkspaceProject(ctx.config.name || ctx.config.root, ctx);
10714
+ project.vitenode = ctx.vitenode;
10715
+ project.server = ctx.server;
10716
+ project.runner = ctx.runner;
10717
+ project.config = ctx.config;
10718
+ await project.initBrowserServer(ctx.server.config.configFile);
10719
+ return project;
10720
+ }
10721
+ async setServer(options, server) {
10697
10722
  this.config = resolveConfig(this.ctx.mode, options, server.config);
10698
10723
  this.server = server;
10699
- this.vitenode = params.server ?? new ViteNodeServer(server, this.config);
10724
+ this.vitenode = new ViteNodeServer(server, this.config);
10700
10725
  const node = this.vitenode;
10701
- this.runner = params.runner ?? new ViteNodeRunner({
10726
+ this.runner = new ViteNodeRunner({
10702
10727
  root: server.config.root,
10703
10728
  base: server.config.base,
10704
10729
  fetchModule(id) {
@@ -10708,7 +10733,7 @@ class WorkspaceProject {
10708
10733
  return node.resolveId(id, importer);
10709
10734
  }
10710
10735
  });
10711
- await this.initBrowserServer(options);
10736
+ await this.initBrowserServer(this.server.config.configFile);
10712
10737
  }
10713
10738
  async report(name, ...args) {
10714
10739
  return this.ctx.report(name, ...args);
@@ -10925,18 +10950,13 @@ class Vitest {
10925
10950
  } catch {
10926
10951
  }
10927
10952
  await Promise.all(this._onSetServer.map((fn) => fn()));
10928
- this.projects = await this.resolveWorkspace(options, cliOptions);
10953
+ this.projects = await this.resolveWorkspace(cliOptions);
10929
10954
  if (this.config.testNamePattern)
10930
10955
  this.configOverride.testNamePattern = this.config.testNamePattern;
10931
10956
  }
10932
- async createCoreWorkspace(options) {
10933
- const coreWorkspace = new WorkspaceProject(this.config.root, this);
10934
- await coreWorkspace.setServer(options, this.server, {
10935
- runner: this.runner,
10936
- server: this.vitenode
10937
- });
10938
- this.coreWorkspaceProject = coreWorkspace;
10939
- return coreWorkspace;
10957
+ async createCoreProject() {
10958
+ this.coreWorkspaceProject = await WorkspaceProject.createCoreProject(this);
10959
+ return this.coreWorkspaceProject;
10940
10960
  }
10941
10961
  getCoreWorkspaceProject() {
10942
10962
  return this.coreWorkspaceProject || null;
@@ -10947,14 +10967,14 @@ class Vitest {
10947
10967
  const projectName = task.projectName || ((_a = task == null ? void 0 : task.file) == null ? void 0 : _a.projectName);
10948
10968
  return this.projects.find((p) => p.getName() === projectName) || this.getCoreWorkspaceProject() || this.projects[0];
10949
10969
  }
10950
- async resolveWorkspace(options, cliOptions) {
10970
+ async resolveWorkspace(cliOptions) {
10951
10971
  const configDir = this.server.config.configFile ? dirname(this.server.config.configFile) : this.config.root;
10952
10972
  const rootFiles = await promises.readdir(configDir);
10953
10973
  const workspaceConfigName = workspacesFiles.find((configFile) => {
10954
10974
  return rootFiles.includes(configFile);
10955
10975
  });
10956
10976
  if (!workspaceConfigName)
10957
- return [await this.createCoreWorkspace(options)];
10977
+ return [await this.createCoreProject()];
10958
10978
  const workspaceConfigPath = join(configDir, workspaceConfigName);
10959
10979
  const workspaceModule = await this.runner.executeFile(workspaceConfigPath);
10960
10980
  if (!workspaceModule.default || !Array.isArray(workspaceModule.default))
@@ -11023,14 +11043,14 @@ class Vitest {
11023
11043
  }, {});
11024
11044
  const projects = filteredWorkspaces.map(async (workspacePath) => {
11025
11045
  if (this.server.config.configFile === workspacePath)
11026
- return this.createCoreWorkspace(options);
11046
+ return this.createCoreProject();
11027
11047
  return initializeProject(workspacePath, this, { workspaceConfigPath, test: cliOverrides });
11028
11048
  });
11029
- projectsOptions.forEach((options2, index) => {
11030
- projects.push(initializeProject(index, this, mergeConfig(options2, { workspaceConfigPath, test: cliOverrides })));
11049
+ projectsOptions.forEach((options, index) => {
11050
+ projects.push(initializeProject(index, this, mergeConfig(options, { workspaceConfigPath, test: cliOverrides })));
11031
11051
  });
11032
11052
  if (!projects.length)
11033
- return [await this.createCoreWorkspace(options)];
11053
+ return [await this.createCoreProject()];
11034
11054
  const resolvedProjects = await Promise.all(projects);
11035
11055
  const names = /* @__PURE__ */ new Set();
11036
11056
  for (const project of resolvedProjects) {
@@ -11379,10 +11399,8 @@ class Vitest {
11379
11399
  async reportCoverage(allTestsRun) {
11380
11400
  if (!this.config.coverage.reportOnFailure && this.state.getCountOfFailedTests() > 0)
11381
11401
  return;
11382
- if (this.coverageProvider) {
11383
- this.logger.log(c.blue(" % ") + c.dim("Coverage report from ") + c.yellow(this.coverageProvider.name));
11402
+ if (this.coverageProvider)
11384
11403
  await this.coverageProvider.reportCoverage({ allTestsRun });
11385
- }
11386
11404
  }
11387
11405
  async close() {
11388
11406
  if (!this.closingPromise) {
@@ -11493,7 +11511,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11493
11511
  testConfig.api = resolveApiServerConfig(testConfig);
11494
11512
  const defines = deleteDefineConfig(viteConfig);
11495
11513
  options.defines = defines;
11496
- let open;
11514
+ let open = false;
11497
11515
  if (testConfig.ui && testConfig.open)
11498
11516
  open = testConfig.uiBase ?? "/__vitest__/";
11499
11517
  const config = {
@@ -11544,7 +11562,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11544
11562
  return config;
11545
11563
  },
11546
11564
  async configResolved(viteConfig) {
11547
- var _a, _b, _c, _d;
11565
+ var _a, _b, _c;
11548
11566
  const viteConfigTest = viteConfig.test || {};
11549
11567
  if (viteConfigTest.watch === false)
11550
11568
  viteConfigTest.run = true;
@@ -11560,9 +11578,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11560
11578
  const { PROD, DEV, ...envs } = viteConfig.env;
11561
11579
  (_a = process.env).PROD ?? (_a.PROD = PROD ? "1" : "");
11562
11580
  (_b = process.env).DEV ?? (_b.DEV = DEV ? "1" : "");
11563
- (_c = process.env).SSR ?? (_c.SSR = "1");
11564
11581
  for (const name in envs)
11565
- (_d = process.env)[name] ?? (_d[name] = envs[name]);
11582
+ (_c = process.env)[name] ?? (_c[name] = envs[name]);
11566
11583
  if (!options.watch) {
11567
11584
  viteConfig.server.watch = {
11568
11585
  persistent: false,
@@ -11581,7 +11598,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11581
11598
  try {
11582
11599
  await ctx.setServer(options, server, userConfig);
11583
11600
  if (options.api && options.watch)
11584
- (await import('./chunk-api-setup.3b016b1c.js')).setup(ctx);
11601
+ (await import('./chunk-api-setup.d65b007d.js')).setup(ctx);
11585
11602
  } catch (err) {
11586
11603
  await ctx.logger.printError(err, { fullStack: true });
11587
11604
  process.exit(1);
@@ -11602,7 +11619,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11602
11619
  }
11603
11620
 
11604
11621
  async function createVitest(mode, options, viteOverrides = {}) {
11605
- var _a, _b, _c, _d, _e, _f, _g;
11622
+ var _a;
11606
11623
  const ctx = new Vitest(mode);
11607
11624
  const root = resolve(options.root || process.cwd());
11608
11625
  const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
@@ -11614,11 +11631,9 @@ async function createVitest(mode, options, viteOverrides = {}) {
11614
11631
  mode: options.mode || process.env.NODE_ENV || mode,
11615
11632
  plugins: await VitestPlugin(options, ctx)
11616
11633
  };
11617
- const server = await createServer(mergeConfig(config, mergeConfig(viteOverrides, { root: options.root })));
11618
- if (((_a = ctx.config.api) == null ? void 0 : _a.port) || ((_d = (_c = (_b = ctx.config.deps) == null ? void 0 : _b.optimizer) == null ? void 0 : _c.web) == null ? void 0 : _d.enabled) || ((_g = (_f = (_e = ctx.config.deps) == null ? void 0 : _e.optimizer) == null ? void 0 : _f.ssr) == null ? void 0 : _g.enabled))
11634
+ const server = await createViteServer(mergeConfig(config, mergeConfig(viteOverrides, { root: options.root })));
11635
+ if ((_a = ctx.config.api) == null ? void 0 : _a.port)
11619
11636
  await server.listen();
11620
- else
11621
- await server.pluginContainer.buildStart({});
11622
11637
  return ctx;
11623
11638
  }
11624
11639
 
@@ -3205,7 +3205,7 @@ function createVitest() {
3205
3205
  const stack = parseSingleStack(importerStack);
3206
3206
  return (stack == null ? void 0 : stack.file) || "";
3207
3207
  };
3208
- return {
3208
+ const utils = {
3209
3209
  useFakeTimers(config) {
3210
3210
  if (config) {
3211
3211
  _timers.configure(config);
@@ -3214,48 +3214,48 @@ function createVitest() {
3214
3214
  _timers.configure(workerState2.config.fakeTimers);
3215
3215
  }
3216
3216
  _timers.useFakeTimers();
3217
- return this;
3217
+ return utils;
3218
3218
  },
3219
3219
  useRealTimers() {
3220
3220
  _timers.useRealTimers();
3221
3221
  _mockedDate = null;
3222
- return this;
3222
+ return utils;
3223
3223
  },
3224
3224
  runOnlyPendingTimers() {
3225
3225
  _timers.runOnlyPendingTimers();
3226
- return this;
3226
+ return utils;
3227
3227
  },
3228
3228
  async runOnlyPendingTimersAsync() {
3229
3229
  await _timers.runOnlyPendingTimersAsync();
3230
- return this;
3230
+ return utils;
3231
3231
  },
3232
3232
  runAllTimers() {
3233
3233
  _timers.runAllTimers();
3234
- return this;
3234
+ return utils;
3235
3235
  },
3236
3236
  async runAllTimersAsync() {
3237
3237
  await _timers.runAllTimersAsync();
3238
- return this;
3238
+ return utils;
3239
3239
  },
3240
3240
  runAllTicks() {
3241
3241
  _timers.runAllTicks();
3242
- return this;
3242
+ return utils;
3243
3243
  },
3244
3244
  advanceTimersByTime(ms) {
3245
3245
  _timers.advanceTimersByTime(ms);
3246
- return this;
3246
+ return utils;
3247
3247
  },
3248
3248
  async advanceTimersByTimeAsync(ms) {
3249
3249
  await _timers.advanceTimersByTimeAsync(ms);
3250
- return this;
3250
+ return utils;
3251
3251
  },
3252
3252
  advanceTimersToNextTimer() {
3253
3253
  _timers.advanceTimersToNextTimer();
3254
- return this;
3254
+ return utils;
3255
3255
  },
3256
3256
  async advanceTimersToNextTimerAsync() {
3257
3257
  await _timers.advanceTimersToNextTimerAsync();
3258
- return this;
3258
+ return utils;
3259
3259
  },
3260
3260
  getTimerCount() {
3261
3261
  return _timers.getTimerCount();
@@ -3264,7 +3264,7 @@ function createVitest() {
3264
3264
  const date = time instanceof Date ? time : new Date(time);
3265
3265
  _mockedDate = date;
3266
3266
  _timers.setSystemTime(date);
3267
- return this;
3267
+ return utils;
3268
3268
  },
3269
3269
  getMockedSystemTime() {
3270
3270
  return _mockedDate;
@@ -3274,7 +3274,7 @@ function createVitest() {
3274
3274
  },
3275
3275
  clearAllTimers() {
3276
3276
  _timers.clearAllTimers();
3277
- return this;
3277
+ return utils;
3278
3278
  },
3279
3279
  // mocks
3280
3280
  spyOn,
@@ -3314,15 +3314,15 @@ function createVitest() {
3314
3314
  },
3315
3315
  clearAllMocks() {
3316
3316
  spies.forEach((spy) => spy.mockClear());
3317
- return this;
3317
+ return utils;
3318
3318
  },
3319
3319
  resetAllMocks() {
3320
3320
  spies.forEach((spy) => spy.mockReset());
3321
- return this;
3321
+ return utils;
3322
3322
  },
3323
3323
  restoreAllMocks() {
3324
3324
  spies.forEach((spy) => spy.mockRestore());
3325
- return this;
3325
+ return utils;
3326
3326
  },
3327
3327
  stubGlobal(name, value) {
3328
3328
  if (!_stubsGlobal.has(name))
@@ -3333,13 +3333,13 @@ function createVitest() {
3333
3333
  configurable: true,
3334
3334
  enumerable: true
3335
3335
  });
3336
- return this;
3336
+ return utils;
3337
3337
  },
3338
3338
  stubEnv(name, value) {
3339
3339
  if (!_stubsEnv.has(name))
3340
3340
  _stubsEnv.set(name, process.env[name]);
3341
3341
  process.env[name] = value;
3342
- return this;
3342
+ return utils;
3343
3343
  },
3344
3344
  unstubAllGlobals() {
3345
3345
  _stubsGlobal.forEach((original, name) => {
@@ -3349,7 +3349,7 @@ function createVitest() {
3349
3349
  Object.defineProperty(globalThis, name, original);
3350
3350
  });
3351
3351
  _stubsGlobal.clear();
3352
- return this;
3352
+ return utils;
3353
3353
  },
3354
3354
  unstubAllEnvs() {
3355
3355
  _stubsEnv.forEach((original, name) => {
@@ -3359,12 +3359,12 @@ function createVitest() {
3359
3359
  process.env[name] = original;
3360
3360
  });
3361
3361
  _stubsEnv.clear();
3362
- return this;
3362
+ return utils;
3363
3363
  },
3364
3364
  resetModules() {
3365
3365
  const state = getWorkerState();
3366
3366
  resetModules(state.moduleCache);
3367
- return this;
3367
+ return utils;
3368
3368
  },
3369
3369
  async dynamicImportSettled() {
3370
3370
  return waitForImportsToResolve();
@@ -3382,6 +3382,7 @@ function createVitest() {
3382
3382
  }
3383
3383
  }
3384
3384
  };
3385
+ return utils;
3385
3386
  }
3386
3387
  const vitest = createVitest();
3387
3388
  const vi = vitest;
package/dist/vm.js CHANGED
@@ -7,7 +7,7 @@ import { c as createBirpc } from './vendor-index.b271ebe4.js';
7
7
  import { resolve } from 'pathe';
8
8
  import { installSourcemapsSupport } from 'vite-node/source-map';
9
9
  import { d as distDir } from './vendor-paths.84fc7a99.js';
10
- import { l as loadEnvironment } from './vendor-environments.8eb4d407.js';
10
+ import { l as loadEnvironment } from './vendor-environments.c9c96bf7.js';
11
11
  import { b as startVitestExecutor } from './vendor-execute.a63e187f.js';
12
12
  import { createCustomConsole } from './chunk-runtime-console.ea222ffb.js';
13
13
  import { c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
package/dist/worker.js CHANGED
@@ -2,7 +2,7 @@ import { performance } from 'node:perf_hooks';
2
2
  import { c as createBirpc } from './vendor-index.b271ebe4.js';
3
3
  import { workerId } from 'tinypool';
4
4
  import { g as getWorkerState } from './vendor-global.97e4527c.js';
5
- import { l as loadEnvironment } from './vendor-environments.8eb4d407.js';
5
+ import { l as loadEnvironment } from './vendor-environments.c9c96bf7.js';
6
6
  import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.a63e187f.js';
7
7
  import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
8
8
  import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.34.3",
4
+ "version": "0.34.4",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -153,14 +153,14 @@
153
153
  "strip-literal": "^1.0.1",
154
154
  "tinybench": "^2.5.0",
155
155
  "tinypool": "^0.7.0",
156
- "vite": "^3.0.0 || ^4.0.0",
156
+ "vite": "^3.1.0 || ^4.0.0 || ^5.0.0-0",
157
157
  "why-is-node-running": "^2.2.2",
158
- "@vitest/runner": "0.34.3",
159
- "@vitest/utils": "0.34.3",
160
- "vite-node": "0.34.3",
161
- "@vitest/expect": "0.34.3",
162
- "@vitest/snapshot": "0.34.3",
163
- "@vitest/spy": "0.34.3"
158
+ "@vitest/runner": "0.34.4",
159
+ "@vitest/snapshot": "0.34.4",
160
+ "vite-node": "0.34.4",
161
+ "@vitest/utils": "0.34.4",
162
+ "@vitest/expect": "0.34.4",
163
+ "@vitest/spy": "0.34.4"
164
164
  },
165
165
  "devDependencies": {
166
166
  "@ampproject/remapping": "^2.2.1",