vitest 1.0.4 → 1.1.0

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 { processError, startTests } from '@vitest/runner';
2
- import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-OH1c16Kq.js';
2
+ import { R as ResolvedConfig, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule } from './reporters-O4LBziQ_.js';
3
3
  import { VitestExecutor } from './execute.js';
4
4
  import 'vite';
5
5
  import 'vite-node';
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.vEetZgP7.js';
4
+ import { v as version, s as startVitest } from './vendor/node.i3Lxw5di.js';
5
5
  import './vendor/index.XU72Rmy8.js';
6
6
  import { d as divider } from './vendor/reporters.r0gTYN3L.js';
7
7
  import { t as toArray } from './vendor/base._79unx2z.js';
@@ -57,7 +57,7 @@ import './vendor/date.Ns1pGd_X.js';
57
57
  import './vendor/tasks.IknbGB2n.js';
58
58
 
59
59
  const cli = cac("vitest");
60
- cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--coverage.all", "Whether to include all files, including the untested ones into report", { default: true }).option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser API with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed (default: 0)").option("--retry <times>", "Retry the test specific number of times if it fails (default: 0)").option("--diff <path>", "Path to a diff config that will be used to generate diff interface").option("--expand-snapshot-diff", "Show full diff when snapshot fails").option("--typecheck [options]", "Custom options for typecheck pool").option("--typecheck.enabled", "Enable typechecking alongside tests (default: false)").option("--typecheck.only", "Run only typecheck tests. This automatically enables typecheck (default: false)").option("--project <name>", "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2").help();
60
+ cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--coverage.all", "Whether to include all files, including the untested ones into report", { default: true }).option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--workspace <path>", "Path to a workspace configuration file").option("--isolate", "Run every test file in isolation. To disable isolation, use --no-isolate (default: true)").option("--globals", "Inject apis globally").option("--dom", "Mock browser API with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--pool <pool>", "Specify pool, if not running in the browser (default: threads)").option("--poolOptions <options>", "Specify pool options").option("--poolOptions.threads.isolate", "Isolate tests in threads pool (default: true)").option("--poolOptions.forks.isolate", "Isolate tests in forks pool (default: true)").option("--fileParallelism", "Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)").option("--maxWorkers", "Maximum number of workers to run tests in").option("--minWorkers", "Minimum number of workers to run tests in").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed (default: 0)").option("--retry <times>", "Retry the test specific number of times if it fails (default: 0)").option("--diff <path>", "Path to a diff config that will be used to generate diff interface").option("--exclude <glob>", "Additional file globs to be excluded from test").option("--expand-snapshot-diff", "Show full diff when snapshot fails").option("--typecheck [options]", "Custom options for typecheck pool").option("--typecheck.enabled", "Enable typechecking alongside tests (default: false)").option("--typecheck.only", "Run only typecheck tests. This automatically enables typecheck (default: false)").option("--project <name>", "The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2").help();
61
61
  cli.command("run [...filters]").action(run);
62
62
  cli.command("related [...filters]").action(runRelated);
63
63
  cli.command("watch [...filters]").action(watch);
@@ -110,10 +110,18 @@ function normalizeCliOptions(argv) {
110
110
  argv.config = normalize(argv.config);
111
111
  else
112
112
  delete argv.config;
113
+ if (argv.workspace)
114
+ argv.workspace = normalize(argv.workspace);
115
+ else
116
+ delete argv.workspace;
113
117
  if (argv.dir)
114
118
  argv.dir = normalize(argv.dir);
115
119
  else
116
120
  delete argv.dir;
121
+ if (argv.exclude) {
122
+ argv.cliExclude = toArray(argv.exclude);
123
+ delete argv.exclude;
124
+ }
117
125
  if (argv.coverage) {
118
126
  const coverage = argv.coverage;
119
127
  if (coverage.exclude)
package/dist/config.cjs CHANGED
@@ -57,6 +57,7 @@ const fakeTimersDefaults = {
57
57
  };
58
58
  const config = {
59
59
  allowOnly: !stdEnv.isCI,
60
+ isolate: true,
60
61
  watch: !stdEnv.isCI,
61
62
  globals: false,
62
63
  environment: "node",
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
1
+ import { UserConfig, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
- import { a as ResolvedCoverageOptions, U as UserConfig, C as CoverageV8Options, P as ProjectConfig } from './reporters-OH1c16Kq.js';
3
+ import { a as ResolvedCoverageOptions, C as CoverageV8Options, P as ProjectConfig } from './reporters-O4LBziQ_.js';
4
4
  import '@vitest/runner';
5
5
  import 'vite-node';
6
6
  import '@vitest/snapshot';
@@ -18,15 +18,16 @@ import 'chai';
18
18
  declare const defaultInclude: string[];
19
19
  declare const defaultExclude: string[];
20
20
  declare const coverageConfigDefaults: ResolvedCoverageOptions;
21
- declare const config: {
21
+ declare const configDefaults: Readonly<{
22
22
  allowOnly: boolean;
23
+ isolate: true;
23
24
  watch: boolean;
24
- globals: boolean;
25
+ globals: false;
25
26
  environment: "node";
26
27
  pool: "threads";
27
- clearMocks: boolean;
28
- restoreMocks: boolean;
29
- mockReset: boolean;
28
+ clearMocks: false;
29
+ restoreMocks: false;
30
+ mockReset: false;
30
31
  include: string[];
31
32
  exclude: string[];
32
33
  testTimeout: number;
@@ -34,12 +35,12 @@ declare const config: {
34
35
  teardownTimeout: number;
35
36
  watchExclude: string[];
36
37
  forceRerunTriggers: string[];
37
- update: boolean;
38
+ update: false;
38
39
  reporters: never[];
39
- silent: boolean;
40
- hideSkippedTests: boolean;
41
- api: boolean;
42
- ui: boolean;
40
+ silent: false;
41
+ hideSkippedTests: false;
42
+ api: false;
43
+ ui: false;
43
44
  uiBase: string;
44
45
  open: boolean;
45
46
  css: {
@@ -52,33 +53,33 @@ declare const config: {
52
53
  toFake: ("setTimeout" | "setInterval" | "clearInterval" | "clearTimeout" | "setImmediate" | "clearImmediate" | "Date")[];
53
54
  };
54
55
  maxConcurrency: number;
55
- dangerouslyIgnoreUnhandledErrors: boolean;
56
+ dangerouslyIgnoreUnhandledErrors: false;
56
57
  typecheck: {
57
58
  checker: "tsc";
58
59
  include: string[];
59
60
  exclude: string[];
60
61
  };
61
62
  slowTestThreshold: number;
62
- };
63
- declare const configDefaults: Required<Pick<UserConfig, keyof typeof config>>;
63
+ }>;
64
64
 
65
- interface UserWorkspaceConfig extends UserConfig$1 {
65
+ interface UserWorkspaceConfig extends UserConfig {
66
66
  test?: ProjectConfig;
67
67
  }
68
68
 
69
- type UserConfigFnObject = (env: ConfigEnv) => UserConfig$1;
70
- type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig$1>;
71
- type UserConfigFn = (env: ConfigEnv) => UserConfig$1 | Promise<UserConfig$1>;
72
- type UserConfigExport = UserConfig$1 | Promise<UserConfig$1> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
69
+ type UserConfigFnObject = (env: ConfigEnv) => UserConfig;
70
+ type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>;
71
+ type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
72
+ type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
73
73
  type UserProjectConfigFn = (env: ConfigEnv) => UserWorkspaceConfig | Promise<UserWorkspaceConfig>;
74
74
  type UserProjectConfigExport = UserWorkspaceConfig | Promise<UserWorkspaceConfig> | UserProjectConfigFn;
75
- declare function defineConfig(config: UserConfig$1): UserConfig$1;
76
- declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
75
+ declare function defineConfig(config: UserConfig): UserConfig;
76
+ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
77
77
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
78
78
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
79
79
  declare function defineProject<T extends UserProjectConfigExport>(config: T): T;
80
- declare function defineWorkspace<T extends (string | (UserProjectConfigExport & {
80
+ type Workspace = (string | (UserProjectConfigExport & {
81
81
  extends?: string;
82
- }))[]>(config: T): T;
82
+ }));
83
+ declare function defineWorkspace(config: Workspace[]): Workspace[];
83
84
 
84
85
  export { type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, type UserProjectConfigExport, type UserProjectConfigFn, type UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultExclude, defaultInclude, defineConfig, defineProject, defineWorkspace };
package/dist/config.js CHANGED
@@ -55,6 +55,7 @@ const fakeTimersDefaults = {
55
55
  };
56
56
  const config = {
57
57
  allowOnly: !isCI,
58
+ isolate: true,
58
59
  watch: !isCI,
59
60
  globals: false,
60
61
  environment: "node",
@@ -1,4 +1,4 @@
1
- import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-OH1c16Kq.js';
1
+ import { B as BaseCoverageOptions, a as ResolvedCoverageOptions } from './reporters-O4LBziQ_.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
@@ -1,4 +1,4 @@
1
- import { E as Environment } from './reporters-OH1c16Kq.js';
1
+ import { E as Environment } from './reporters-O4LBziQ_.js';
2
2
  import 'vite';
3
3
  import '@vitest/runner';
4
4
  import 'vite-node';
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 { am as PendingSuiteMock, an as MockFactory, ao as MockMap, a2 as WorkerGlobalState, g as RuntimeRPC } from './reporters-OH1c16Kq.js';
4
+ import { am as PendingSuiteMock, an as MockFactory, ao as MockMap, a2 as WorkerGlobalState, g as RuntimeRPC } from './reporters-O4LBziQ_.js';
5
5
  import 'vite';
6
6
  import '@vitest/runner';
7
7
  import '@vitest/snapshot';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { TaskPopulated, File, TaskResultPack, CancelReason } from '@vitest/runner';
2
2
  export { Custom, DoneCallback, ExtendedContext, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskContext, TaskCustomOptions, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- export { b as bench } from './suite-9ReVEt_h.js';
3
+ export { b as bench } from './suite-dF4WyktM.js';
4
4
  import { ExpectStatic } from '@vitest/expect';
5
5
  export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect';
6
- import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, n as RuntimeConfig, f as ProvidedContext, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-OH1c16Kq.js';
7
- export { K as ApiConfig, a6 as ArgumentsType, a5 as Arrayable, a3 as Awaitable, B as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, D as BuiltinEnvironment, I as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a8 as Constructable, x as Context, _ as ContextRPC, Y as ContextTestEnvironment, af as CoverageIstanbulOptions, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule, ae as CoverageReporter, C as CoverageV8Options, ag as CustomProviderOptions, N as DepsOptimizationOptions, E as Environment, L as EnvironmentOptions, aa as EnvironmentReturn, H as HappyDOMOptions, Q as InlineConfig, J as JSDOMOptions, a9 as ModuleCache, a7 as MutableArray, a4 as Nullable, ac as OnServerRestartHandler, y as Pool, z as PoolOptions, P as ProjectConfig, r as RawErrsMap, ad as ReportContext, a0 as ResolveIdFunction, a as ResolvedCoverageOptions, Z as ResolvedTestEnvironment, w as RootAndTarget, X as RunnerRPC, g as RuntimeRPC, O as TransformModePatterns, t as TscErrorInfo, S as TypecheckConfig, U as UserConfig, e as Vitest, G as VitestEnvironment, V as VitestRunMode, ab as VmEnvironmentReturn, $ as WorkerContext, a2 as WorkerGlobalState, a1 as WorkerRPC } from './reporters-OH1c16Kq.js';
6
+ import { F as FakeTimerInstallOpts, M as MockFactoryWithHelper, n as RuntimeConfig, f as ProvidedContext, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './reporters-O4LBziQ_.js';
7
+ export { K as ApiConfig, a6 as ArgumentsType, a5 as Arrayable, a3 as Awaitable, B as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, D as BuiltinEnvironment, I as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a8 as Constructable, x as Context, _ as ContextRPC, Y as ContextTestEnvironment, af as CoverageIstanbulOptions, b as CoverageOptions, c as CoverageProvider, d as CoverageProviderModule, ae as CoverageReporter, C as CoverageV8Options, ag as CustomProviderOptions, N as DepsOptimizationOptions, E as Environment, L as EnvironmentOptions, aa as EnvironmentReturn, H as HappyDOMOptions, Q as InlineConfig, J as JSDOMOptions, a9 as ModuleCache, a7 as MutableArray, a4 as Nullable, ac as OnServerRestartHandler, y as Pool, z as PoolOptions, P as ProjectConfig, r as RawErrsMap, ad as ReportContext, a0 as ResolveIdFunction, a as ResolvedCoverageOptions, Z as ResolvedTestEnvironment, w as RootAndTarget, X as RunnerRPC, g as RuntimeRPC, O as TransformModePatterns, t as TscErrorInfo, S as TypecheckConfig, U as UserConfig, e as Vitest, G as VitestEnvironment, V as VitestRunMode, ab as VmEnvironmentReturn, $ as WorkerContext, a2 as WorkerGlobalState, a1 as WorkerRPC } from './reporters-O4LBziQ_.js';
8
8
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
9
9
  export { Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
10
10
  export { SnapshotEnvironment } from '@vitest/snapshot/environment';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VitestRunMode, U as UserConfig, e as Vitest, R as ResolvedConfig, f as ProvidedContext, W as WorkspaceProject, g as RuntimeRPC, T as TestSequencer, h as WorkspaceSpec } from './reporters-OH1c16Kq.js';
2
- export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, i as ProcessPool, j as TestSequencerConstructor, s as startVitest } from './reporters-OH1c16Kq.js';
1
+ import { V as VitestRunMode, U as UserConfig, e as Vitest, R as ResolvedConfig, f as ProvidedContext, W as WorkspaceProject, g as RuntimeRPC, T as TestSequencer, h as WorkspaceSpec } from './reporters-O4LBziQ_.js';
2
+ export { l as BrowserProvider, k as BrowserProviderInitializationOptions, m as BrowserProviderOptions, i as ProcessPool, j as TestSequencerConstructor, s as startVitest } from './reporters-O4LBziQ_.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, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/node.vEetZgP7.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, a as createMethodsRPC, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor/node.i3Lxw5di.js';
2
2
  import 'pathe';
3
3
  import 'vite';
4
4
  import 'node:path';
@@ -865,6 +865,7 @@ declare class Vitest {
865
865
  private createCoreProject;
866
866
  getCoreWorkspaceProject(): WorkspaceProject;
867
867
  getProjectByTaskId(taskId: string): WorkspaceProject;
868
+ private getWorkspaceConfigPath;
868
869
  private resolveWorkspace;
869
870
  private initCoverageProvider;
870
871
  private initBrowserProviders;
@@ -1882,6 +1883,14 @@ interface InlineConfig {
1882
1883
  * ]
1883
1884
  */
1884
1885
  environmentMatchGlobs?: [string, VitestEnvironment][];
1886
+ /**
1887
+ * Run tests in an isolated environment. This option has no effect on vmThreads pool.
1888
+ *
1889
+ * Disabling this option might improve performance if your code doesn't rely on side effects.
1890
+ *
1891
+ * @default true
1892
+ */
1893
+ isolate?: boolean;
1885
1894
  /**
1886
1895
  * Pool used to run tests in.
1887
1896
  *
@@ -1894,6 +1903,21 @@ interface InlineConfig {
1894
1903
  * Pool options
1895
1904
  */
1896
1905
  poolOptions?: PoolOptions;
1906
+ /**
1907
+ * Maximum number of workers to run tests in. `poolOptions.{threads,vmThreads}.maxThreads`/`poolOptions.forks.maxForks` has higher priority.
1908
+ */
1909
+ maxWorkers?: number;
1910
+ /**
1911
+ * Minimum number of workers to run tests in. `poolOptions.{threads,vmThreads}.minThreads`/`poolOptions.forks.minForks` has higher priority.
1912
+ */
1913
+ minWorkers?: number;
1914
+ /**
1915
+ * Should all test files run in parallel. Doesn't affect tests running in the same file.
1916
+ * Setting this to `false` will override `maxWorkers` and `minWorkers` options to `1`.
1917
+ *
1918
+ * @default true
1919
+ */
1920
+ fileParallelism?: boolean;
1897
1921
  /**
1898
1922
  * Automatically assign pool based on globs. The first match will be used.
1899
1923
  *
@@ -1908,6 +1932,10 @@ interface InlineConfig {
1908
1932
  * ]
1909
1933
  */
1910
1934
  poolMatchGlobs?: [string, Exclude<Pool, 'browser'>][];
1935
+ /**
1936
+ * Path to a workspace configuration file
1937
+ */
1938
+ workspace?: string;
1911
1939
  /**
1912
1940
  * Update snapshot
1913
1941
  *
@@ -2262,8 +2290,12 @@ interface UserConfig extends InlineConfig {
2262
2290
  * Name of the project or projects to run.
2263
2291
  */
2264
2292
  project?: string | string[];
2293
+ /**
2294
+ * Additional exclude patterns
2295
+ */
2296
+ cliExclude?: string[];
2265
2297
  }
2266
- interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool'> {
2298
+ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters' | 'browser' | 'coverage' | 'testNamePattern' | 'related' | 'api' | 'reporters' | 'resolveSnapshotPath' | 'benchmark' | 'shard' | 'cache' | 'sequence' | 'typecheck' | 'runner' | 'poolOptions' | 'pool' | 'cliExclude'> {
2267
2299
  mode: VitestRunMode;
2268
2300
  base?: string;
2269
2301
  config?: string;
@@ -2278,6 +2310,7 @@ interface ResolvedConfig extends Omit<Required<UserConfig>, 'config' | 'filters'
2278
2310
  reporters: (Reporter | BuiltinReporters)[];
2279
2311
  defines: Record<string, any>;
2280
2312
  api?: ApiConfig;
2313
+ cliExclude?: string[];
2281
2314
  benchmark?: Required<Omit<BenchmarkUserOptions, 'outputFile'>> & Pick<BenchmarkUserOptions, 'outputFile'>;
2282
2315
  shard?: {
2283
2316
  index: number;
@@ -1,4 +1,4 @@
1
- export { ay as BaseReporter, aq as BasicReporter, aC as BenchmarkBuiltinReporters, aB as BenchmarkReportsMap, aA as BuiltinReporters, ap as DefaultReporter, ar as DotReporter, ax as HangingProcessReporter, av as JUnitReporter, as as JsonReporter, q as Reporter, az as ReportersMap, aw as TapFlatReporter, au as TapReporter, at as VerboseReporter } from './reporters-OH1c16Kq.js';
1
+ export { ay as BaseReporter, aq as BasicReporter, aC as BenchmarkBuiltinReporters, aB as BenchmarkReportsMap, aA as BuiltinReporters, ap as DefaultReporter, ar as DotReporter, ax as HangingProcessReporter, av as JUnitReporter, as as JsonReporter, q as Reporter, az as ReportersMap, aw as TapFlatReporter, au as TapReporter, at as VerboseReporter } from './reporters-O4LBziQ_.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, Custom, TaskContext, ExtendedContext } from '@vitest/runner';
2
- import { R as ResolvedConfig } from './reporters-OH1c16Kq.js';
2
+ import { R as ResolvedConfig } from './reporters-O4LBziQ_.js';
3
3
  import * as tinybench from 'tinybench';
4
4
  import 'vite';
5
5
  import 'vite-node';
@@ -1,6 +1,6 @@
1
1
  import { Custom } from '@vitest/runner';
2
2
  import '@vitest/runner/utils';
3
- import { ak as BenchFunction, al as BenchmarkAPI } from './reporters-OH1c16Kq.js';
3
+ import { ak as BenchFunction, al as BenchmarkAPI } from './reporters-O4LBziQ_.js';
4
4
  import { Options } from 'tinybench';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
package/dist/suite.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { createTaskCollector, getCurrentSuite, getFn, setFn } from '@vitest/runner';
2
2
  export { createChainable } from '@vitest/runner/utils';
3
- export { g as getBenchFn, a as getBenchOptions } from './suite-9ReVEt_h.js';
4
- import './reporters-OH1c16Kq.js';
3
+ export { g as getBenchFn, a as getBenchOptions } from './suite-dF4WyktM.js';
4
+ import './reporters-O4LBziQ_.js';
5
5
  import 'vite';
6
6
  import 'vite-node';
7
7
  import '@vitest/snapshot';
@@ -63,7 +63,7 @@ function _mergeNamespaces(n, m) {
63
63
  return Object.freeze(n);
64
64
  }
65
65
 
66
- var version$1 = "1.0.4";
66
+ var version$1 = "1.1.0";
67
67
 
68
68
  const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
69
69
  async function ensurePackageInstalled(dependency, root) {
@@ -3251,11 +3251,12 @@ function stringifyRegex(input) {
3251
3251
  return `$$vitest:${input.toString()}`;
3252
3252
  }
3253
3253
  function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
3254
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3254
+ var _a;
3255
3255
  const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
3256
3256
  const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
3257
- const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.forks) == null ? void 0 : _b.maxForks) ?? threadsCount;
3258
- const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.forks) == null ? void 0 : _d.minForks) ?? threadsCount;
3257
+ const poolOptions = ((_a = ctx.config.poolOptions) == null ? void 0 : _a.forks) ?? {};
3258
+ const maxThreads = poolOptions.maxForks ?? ctx.config.maxWorkers ?? threadsCount;
3259
+ const minThreads = poolOptions.minForks ?? ctx.config.minWorkers ?? threadsCount;
3259
3260
  const options = {
3260
3261
  runtime: "child_process",
3261
3262
  filename: forksPath,
@@ -3263,17 +3264,16 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
3263
3264
  minThreads,
3264
3265
  env,
3265
3266
  execArgv: [
3266
- ...((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.execArgv) ?? [],
3267
+ ...poolOptions.execArgv ?? [],
3267
3268
  ...execArgv
3268
3269
  ],
3269
- terminateTimeout: ctx.config.teardownTimeout
3270
+ terminateTimeout: ctx.config.teardownTimeout,
3271
+ concurrentTasksPerWorker: 1
3270
3272
  };
3271
- if (((_h = (_g = ctx.config.poolOptions) == null ? void 0 : _g.forks) == null ? void 0 : _h.isolate) ?? true) {
3273
+ const isolated = poolOptions.isolate ?? true;
3274
+ if (isolated)
3272
3275
  options.isolateWorkers = true;
3273
- options.concurrentTasksPerWorker = 1;
3274
- }
3275
- if ((_j = (_i = ctx.config.poolOptions) == null ? void 0 : _i.forks) == null ? void 0 : _j.singleFork) {
3276
- options.concurrentTasksPerWorker = 1;
3276
+ if (poolOptions.singleFork || !ctx.config.fileParallelism) {
3277
3277
  options.maxThreads = 1;
3278
3278
  options.minThreads = 1;
3279
3279
  }
@@ -3307,7 +3307,6 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
3307
3307
  }
3308
3308
  }
3309
3309
  return async (specs, invalidates) => {
3310
- var _a2, _b2;
3311
3310
  ctx.onCancel(() => pool.cancelPendingTasks());
3312
3311
  const configs = /* @__PURE__ */ new Map();
3313
3312
  const getConfig = (project) => {
@@ -3329,18 +3328,18 @@ function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
3329
3328
  workspaceMap.set(file, workspaceFiles);
3330
3329
  }
3331
3330
  const singleFork = specs.filter(([project]) => {
3332
- var _a3, _b3;
3333
- return (_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.forks) == null ? void 0 : _b3.singleFork;
3331
+ var _a2, _b;
3332
+ return (_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b.singleFork;
3334
3333
  });
3335
3334
  const multipleForks = specs.filter(([project]) => {
3336
- var _a3, _b3;
3337
- return !((_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.forks) == null ? void 0 : _b3.singleFork);
3335
+ var _a2, _b;
3336
+ return !((_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b.singleFork);
3338
3337
  });
3339
3338
  if (multipleForks.length) {
3340
3339
  const filesByEnv = await groupFilesByEnv(multipleForks);
3341
3340
  const files = Object.values(filesByEnv).flat();
3342
3341
  const results = [];
3343
- if (((_b2 = (_a2 = ctx.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b2.isolate) ?? true) {
3342
+ if (isolated) {
3344
3343
  results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
3345
3344
  } else {
3346
3345
  const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
@@ -3402,31 +3401,31 @@ function createWorkerChannel$1(project) {
3402
3401
  return { workerPort, port };
3403
3402
  }
3404
3403
  function createThreadsPool(ctx, { execArgv, env, workerPath }) {
3405
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3404
+ var _a;
3406
3405
  const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
3407
3406
  const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
3408
- const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.maxThreads) ?? threadsCount;
3409
- const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.minThreads) ?? threadsCount;
3407
+ const poolOptions = ((_a = ctx.config.poolOptions) == null ? void 0 : _a.threads) ?? {};
3408
+ const maxThreads = poolOptions.maxThreads ?? ctx.config.maxWorkers ?? threadsCount;
3409
+ const minThreads = poolOptions.minThreads ?? ctx.config.minWorkers ?? threadsCount;
3410
3410
  const options = {
3411
3411
  filename: workerPath,
3412
3412
  // TODO: investigate further
3413
3413
  // It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
3414
- useAtomics: ((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.threads) == null ? void 0 : _f.useAtomics) ?? false,
3414
+ useAtomics: poolOptions.useAtomics ?? false,
3415
3415
  maxThreads,
3416
3416
  minThreads,
3417
3417
  env,
3418
3418
  execArgv: [
3419
- ...((_h = (_g = ctx.config.poolOptions) == null ? void 0 : _g.threads) == null ? void 0 : _h.execArgv) ?? [],
3419
+ ...poolOptions.execArgv ?? [],
3420
3420
  ...execArgv
3421
3421
  ],
3422
- terminateTimeout: ctx.config.teardownTimeout
3422
+ terminateTimeout: ctx.config.teardownTimeout,
3423
+ concurrentTasksPerWorker: 1
3423
3424
  };
3424
- if (((_j = (_i = ctx.config.poolOptions) == null ? void 0 : _i.threads) == null ? void 0 : _j.isolate) ?? true) {
3425
+ const isolated = poolOptions.isolate ?? true;
3426
+ if (isolated)
3425
3427
  options.isolateWorkers = true;
3426
- options.concurrentTasksPerWorker = 1;
3427
- }
3428
- if ((_l = (_k = ctx.config.poolOptions) == null ? void 0 : _k.threads) == null ? void 0 : _l.singleThread) {
3429
- options.concurrentTasksPerWorker = 1;
3428
+ if (poolOptions.singleThread || !ctx.config.fileParallelism) {
3430
3429
  options.maxThreads = 1;
3431
3430
  options.minThreads = 1;
3432
3431
  }
@@ -3462,7 +3461,6 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
3462
3461
  }
3463
3462
  }
3464
3463
  return async (specs, invalidates) => {
3465
- var _a2, _b2;
3466
3464
  ctx.onCancel(() => pool.cancelPendingTasks());
3467
3465
  const configs = /* @__PURE__ */ new Map();
3468
3466
  const getConfig = (project) => {
@@ -3479,18 +3477,18 @@ function createThreadsPool(ctx, { execArgv, env, workerPath }) {
3479
3477
  workspaceMap.set(file, workspaceFiles);
3480
3478
  }
3481
3479
  const singleThreads = specs.filter(([project]) => {
3482
- var _a3, _b3;
3483
- return (_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.threads) == null ? void 0 : _b3.singleThread;
3480
+ var _a2, _b;
3481
+ return (_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b.singleThread;
3484
3482
  });
3485
3483
  const multipleThreads = specs.filter(([project]) => {
3486
- var _a3, _b3;
3487
- return !((_b3 = (_a3 = project.config.poolOptions) == null ? void 0 : _a3.threads) == null ? void 0 : _b3.singleThread);
3484
+ var _a2, _b;
3485
+ return !((_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b.singleThread);
3488
3486
  });
3489
3487
  if (multipleThreads.length) {
3490
3488
  const filesByEnv = await groupFilesByEnv(multipleThreads);
3491
3489
  const files = Object.values(filesByEnv).flat();
3492
3490
  const results = [];
3493
- if (((_b2 = (_a2 = ctx.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b2.isolate) ?? true) {
3491
+ if (isolated) {
3494
3492
  results.push(...await Promise.allSettled(files.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
3495
3493
  } else {
3496
3494
  const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
@@ -3690,16 +3688,17 @@ function createWorkerChannel(project) {
3690
3688
  return { workerPort, port };
3691
3689
  }
3692
3690
  function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
3693
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
3691
+ var _a;
3694
3692
  const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
3695
3693
  const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
3696
- const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.vmThreads) == null ? void 0 : _b.maxThreads) ?? threadsCount;
3697
- const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.vmThreads) == null ? void 0 : _d.minThreads) ?? threadsCount;
3694
+ const poolOptions = ((_a = ctx.config.poolOptions) == null ? void 0 : _a.vmThreads) ?? {};
3695
+ const maxThreads = poolOptions.maxThreads ?? ctx.config.maxWorkers ?? threadsCount;
3696
+ const minThreads = poolOptions.minThreads ?? ctx.config.minWorkers ?? threadsCount;
3698
3697
  const options = {
3699
3698
  filename: vmPath,
3700
3699
  // TODO: investigate further
3701
3700
  // It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
3702
- useAtomics: ((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.vmThreads) == null ? void 0 : _f.useAtomics) ?? false,
3701
+ useAtomics: poolOptions.useAtomics ?? false,
3703
3702
  maxThreads,
3704
3703
  minThreads,
3705
3704
  env,
@@ -3708,14 +3707,14 @@ function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
3708
3707
  "--experimental-vm-modules",
3709
3708
  "--require",
3710
3709
  suppressWarningsPath,
3711
- ...((_h = (_g = ctx.config.poolOptions) == null ? void 0 : _g.vmThreads) == null ? void 0 : _h.execArgv) ?? [],
3710
+ ...poolOptions.execArgv ?? [],
3712
3711
  ...execArgv
3713
3712
  ],
3714
3713
  terminateTimeout: ctx.config.teardownTimeout,
3714
+ concurrentTasksPerWorker: 1,
3715
3715
  maxMemoryLimitBeforeRecycle: getMemoryLimit(ctx.config) || void 0
3716
3716
  };
3717
- if ((_j = (_i = ctx.config.poolOptions) == null ? void 0 : _i.vmThreads) == null ? void 0 : _j.singleThread) {
3718
- options.concurrentTasksPerWorker = 1;
3717
+ if (poolOptions.singleThread || !ctx.config.fileParallelism) {
3719
3718
  options.maxThreads = 1;
3720
3719
  options.minThreads = 1;
3721
3720
  }
@@ -4351,7 +4350,7 @@ function createTypecheckPool(ctx) {
4351
4350
  setTimeout(() => {
4352
4351
  resolve(false);
4353
4352
  clearInterval(_i);
4354
- }, 500);
4353
+ }, 500).unref();
4355
4354
  });
4356
4355
  const triggered = await _p;
4357
4356
  if (project.typechecker && !triggered) {
@@ -4750,6 +4749,7 @@ const fakeTimersDefaults = {
4750
4749
  };
4751
4750
  const config = {
4752
4751
  allowOnly: !isCI,
4752
+ isolate: true,
4753
4753
  watch: !isCI,
4754
4754
  globals: false,
4755
4755
  environment: "node",
@@ -4978,6 +4978,11 @@ const extraInlineDeps = [
4978
4978
  // Nuxt
4979
4979
  "@nuxt/test-utils"
4980
4980
  ];
4981
+ function resolvePath(path, root) {
4982
+ return normalize(
4983
+ resolveModule(path, { paths: [root] }) ?? resolve(root, path)
4984
+ );
4985
+ }
4981
4986
  function resolveApiServerConfig(options) {
4982
4987
  let api;
4983
4988
  if (options.ui && !options.api)
@@ -5040,12 +5045,17 @@ function resolveConfig(mode, options, viteConfig) {
5040
5045
  throw new Error("--shard <index> must be a positive number less then <count>");
5041
5046
  resolved.shard = { index, count };
5042
5047
  }
5048
+ resolved.fileParallelism ?? (resolved.fileParallelism = true);
5049
+ if (!resolved.fileParallelism) {
5050
+ resolved.maxWorkers = 1;
5051
+ resolved.minWorkers = 1;
5052
+ }
5043
5053
  if (resolved.inspect || resolved.inspectBrk) {
5044
5054
  const isSingleThread = resolved.pool === "threads" && ((_c = (_b = resolved.poolOptions) == null ? void 0 : _b.threads) == null ? void 0 : _c.singleThread);
5045
5055
  const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
5046
- if (!isSingleThread && !isSingleFork) {
5056
+ if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
5047
5057
  const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
5048
- throw new Error(`You cannot use ${inspectOption} without "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
5058
+ throw new Error(`You cannot use ${inspectOption} without "--no-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
5049
5059
  }
5050
5060
  }
5051
5061
  if (resolved.coverage.provider === "c8")
@@ -5091,6 +5101,8 @@ function resolveConfig(mode, options, viteConfig) {
5091
5101
  if (resolved.server.deps[option] === void 0)
5092
5102
  resolved.server.deps[option] = resolved.deps[option];
5093
5103
  });
5104
+ if (resolved.cliExclude)
5105
+ resolved.exclude.push(...resolved.cliExclude);
5094
5106
  if (resolved.server.deps.inline !== true) {
5095
5107
  const ssrOptions = viteConfig.ssr;
5096
5108
  if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
@@ -5102,9 +5114,8 @@ function resolveConfig(mode, options, viteConfig) {
5102
5114
  }
5103
5115
  (_r = resolved.server.deps).moduleDirectories ?? (_r.moduleDirectories = []);
5104
5116
  resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
5105
- if (resolved.runner) {
5106
- resolved.runner = resolveModule(resolved.runner, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.runner);
5107
- }
5117
+ if (resolved.runner)
5118
+ resolved.runner = resolvePath(resolved.runner, resolved.root);
5108
5119
  resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
5109
5120
  if (resolved.snapshotFormat && "plugins" in resolved.snapshotFormat)
5110
5121
  resolved.snapshotFormat.plugins = [];
@@ -5164,17 +5175,14 @@ function resolveConfig(mode, options, viteConfig) {
5164
5175
  }
5165
5176
  };
5166
5177
  }
5167
- if (!builtinPools.includes(resolved.pool)) {
5168
- resolved.pool = normalize(
5169
- resolveModule(resolved.pool, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.pool)
5170
- );
5178
+ if (resolved.workspace) {
5179
+ resolved.workspace = options.workspace && options.workspace[0] === "." ? resolve(process.cwd(), options.workspace) : resolvePath(resolved.workspace, resolved.root);
5171
5180
  }
5181
+ if (!builtinPools.includes(resolved.pool))
5182
+ resolved.pool = resolvePath(resolved.pool, resolved.root);
5172
5183
  resolved.poolMatchGlobs = (resolved.poolMatchGlobs || []).map(([glob, pool]) => {
5173
- if (!builtinPools.includes(pool)) {
5174
- pool = normalize(
5175
- resolveModule(pool, { paths: [resolved.root] }) ?? resolve(resolved.root, pool)
5176
- );
5177
- }
5184
+ if (!builtinPools.includes(pool))
5185
+ pool = resolvePath(pool, resolved.root);
5178
5186
  return [glob, pool];
5179
5187
  });
5180
5188
  if (mode === "benchmark") {
@@ -5199,14 +5207,10 @@ function resolveConfig(mode, options, viteConfig) {
5199
5207
  resolved.benchmark.outputFile = options.outputFile;
5200
5208
  }
5201
5209
  resolved.setupFiles = toArray(resolved.setupFiles || []).map(
5202
- (file) => normalize(
5203
- resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
5204
- )
5210
+ (file) => resolvePath(file, resolved.root)
5205
5211
  );
5206
5212
  resolved.globalSetup = toArray(resolved.globalSetup || []).map(
5207
- (file) => normalize(
5208
- resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
5209
- )
5213
+ (file) => resolvePath(file, resolved.root)
5210
5214
  );
5211
5215
  resolved.coverage.exclude.push(...resolved.setupFiles.map((file) => `${resolved.coverage.allowExternal ? "**/" : ""}${relative(resolved.root, file)}`));
5212
5216
  resolved.forceRerunTriggers = [
@@ -5214,9 +5218,7 @@ function resolveConfig(mode, options, viteConfig) {
5214
5218
  ...resolved.setupFiles
5215
5219
  ];
5216
5220
  if (resolved.diff) {
5217
- resolved.diff = normalize(
5218
- resolveModule(resolved.diff, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.diff)
5219
- );
5221
+ resolved.diff = resolvePath(resolved.diff, resolved.root);
5220
5222
  resolved.forceRerunTriggers.push(resolved.diff);
5221
5223
  }
5222
5224
  resolved.api = resolveApiServerConfig(options);
@@ -6476,7 +6478,7 @@ createLogUpdate(process$2.stdout);
6476
6478
 
6477
6479
  createLogUpdate(process$2.stderr);
6478
6480
 
6479
- var version = "1.0.4";
6481
+ var version = "1.1.0";
6480
6482
 
6481
6483
  async function printError(error, project, options) {
6482
6484
  const { showCodeFrame = true, fullStack = false, type } = options;
@@ -7340,7 +7342,7 @@ function WorkspaceVitestPlugin(project, options) {
7340
7342
  let name = testConfig.name;
7341
7343
  if (!name) {
7342
7344
  if (typeof options.workspacePath === "string")
7343
- name = dirname(options.workspacePath).split("/").pop();
7345
+ name = basename(options.workspacePath.endsWith("/") ? options.workspacePath.slice(0, -1) : dirname(options.workspacePath));
7344
7346
  else
7345
7347
  name = options.workspacePath.toString();
7346
7348
  }
@@ -7461,16 +7463,17 @@ async function loadGlobalSetupFile(file, runner) {
7461
7463
  }
7462
7464
 
7463
7465
  async function initializeProject(workspacePath, ctx, options) {
7466
+ var _a;
7464
7467
  const project = new WorkspaceProject(workspacePath, ctx);
7465
7468
  const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
7466
- const root = options.root || (typeof workspacePath === "number" ? void 0 : dirname(workspacePath));
7469
+ const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
7467
7470
  const config = {
7468
7471
  ...options,
7469
7472
  root,
7470
7473
  logLevel: "error",
7471
7474
  configFile,
7472
7475
  // this will make "mode": "test" | "benchmark" inside defineConfig
7473
- mode: options.mode || ctx.config.mode,
7476
+ mode: ((_a = options.test) == null ? void 0 : _a.mode) || options.mode || ctx.config.mode,
7474
7477
  plugins: [
7475
7478
  ...options.plugins || [],
7476
7479
  WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
@@ -7739,9 +7742,8 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
7739
7742
  this.closingPromise = Promise.all([
7740
7743
  this.server.close(),
7741
7744
  (_a = this.typechecker) == null ? void 0 : _a.stop(),
7742
- (_b = this.browser) == null ? void 0 : _b.close(),
7743
- () => this._provided = {}
7744
- ].filter(Boolean));
7745
+ (_b = this.browser) == null ? void 0 : _b.close()
7746
+ ].filter(Boolean)).then(() => this._provided = {});
7745
7747
  }
7746
7748
  return this.closingPromise;
7747
7749
  }
@@ -7882,15 +7884,22 @@ class Vitest {
7882
7884
  const projectName = task.projectName || ((_a = task == null ? void 0 : task.file) == null ? void 0 : _a.projectName);
7883
7885
  return this.projects.find((p) => p.getName() === projectName) || this.getCoreWorkspaceProject() || this.projects[0];
7884
7886
  }
7885
- async resolveWorkspace(cliOptions) {
7887
+ async getWorkspaceConfigPath() {
7888
+ if (this.config.workspace)
7889
+ return this.config.workspace;
7886
7890
  const configDir = this.server.config.configFile ? dirname(this.server.config.configFile) : this.config.root;
7887
7891
  const rootFiles = await promises.readdir(configDir);
7888
7892
  const workspaceConfigName = workspacesFiles.find((configFile) => {
7889
7893
  return rootFiles.includes(configFile);
7890
7894
  });
7891
7895
  if (!workspaceConfigName)
7896
+ return null;
7897
+ return join(configDir, workspaceConfigName);
7898
+ }
7899
+ async resolveWorkspace(cliOptions) {
7900
+ const workspaceConfigPath = await this.getWorkspaceConfigPath();
7901
+ if (!workspaceConfigPath)
7892
7902
  return [await this.createCoreProject()];
7893
- const workspaceConfigPath = join(configDir, workspaceConfigName);
7894
7903
  const workspaceModule = await this.runner.executeFile(workspaceConfigPath);
7895
7904
  if (!workspaceModule.default || !Array.isArray(workspaceModule.default))
7896
7905
  throw new Error(`Workspace config file ${workspaceConfigPath} must export a default array of project paths.`);
@@ -7929,7 +7938,7 @@ class Vitest {
7929
7938
  return filepath;
7930
7939
  }));
7931
7940
  const workspacesByFolder = resolvedWorkspacesPaths.reduce((configByFolder, filepath) => {
7932
- const dir = dirname(filepath);
7941
+ const dir = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
7933
7942
  configByFolder[dir] ?? (configByFolder[dir] = []);
7934
7943
  configByFolder[dir].push(filepath);
7935
7944
  return configByFolder;
@@ -7947,8 +7956,12 @@ class Vitest {
7947
7956
  "testTimeout",
7948
7957
  "pool",
7949
7958
  "globals",
7950
- "mode",
7951
- "expandSnapshotDiff"
7959
+ "expandSnapshotDiff",
7960
+ "retry",
7961
+ "testNamePattern",
7962
+ "passWithNoTests",
7963
+ "bail",
7964
+ "isolate"
7952
7965
  ];
7953
7966
  const cliOverrides = overridesOptions.reduce((acc, name) => {
7954
7967
  if (name in cliOptions)
@@ -8433,7 +8446,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
8433
8446
  this.meta.watchMode = false;
8434
8447
  },
8435
8448
  async config(viteConfig) {
8436
- var _a, _b, _c, _d;
8449
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
8437
8450
  if (options.watch) {
8438
8451
  options = deepMerge({}, userConfig);
8439
8452
  }
@@ -8444,13 +8457,18 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
8444
8457
  removeUndefinedValues(viteConfig.test ?? {})
8445
8458
  );
8446
8459
  testConfig.api = resolveApiServerConfig(testConfig);
8460
+ testConfig.poolOptions ?? (testConfig.poolOptions = {});
8461
+ (_a = testConfig.poolOptions).threads ?? (_a.threads = {});
8462
+ (_b = testConfig.poolOptions).forks ?? (_b.forks = {});
8463
+ testConfig.poolOptions.threads.isolate = ((_d = (_c = options.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.isolate) ?? options.isolate ?? testConfig.poolOptions.threads.isolate ?? ((_e = viteConfig.test) == null ? void 0 : _e.isolate);
8464
+ testConfig.poolOptions.forks.isolate = ((_g = (_f = options.poolOptions) == null ? void 0 : _f.forks) == null ? void 0 : _g.isolate) ?? options.isolate ?? testConfig.poolOptions.forks.isolate ?? ((_h = viteConfig.test) == null ? void 0 : _h.isolate);
8447
8465
  const defines = deleteDefineConfig(viteConfig);
8448
8466
  options.defines = defines;
8449
8467
  let open = false;
8450
8468
  if (testConfig.ui && testConfig.open)
8451
8469
  open = testConfig.uiBase ?? "/__vitest__/";
8452
8470
  const config = {
8453
- root: ((_a = viteConfig.test) == null ? void 0 : _a.root) || options.root,
8471
+ root: ((_i = viteConfig.test) == null ? void 0 : _i.root) || options.root,
8454
8472
  esbuild: viteConfig.esbuild === false ? false : {
8455
8473
  sourcemap: "external",
8456
8474
  // Enables using ignore hint for coverage providers with @preserve keyword
@@ -8474,16 +8492,19 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
8474
8492
  fs: {
8475
8493
  allow: resolveFsAllow(getRoot(), testConfig.config)
8476
8494
  }
8495
+ },
8496
+ test: {
8497
+ poolOptions: testConfig.poolOptions
8477
8498
  }
8478
8499
  };
8479
8500
  if (process.platform === "darwin" && process.env.VITE_TEST_WATCHER_DEBUG) {
8480
8501
  config.server.watch.useFsEvents = false;
8481
8502
  config.server.watch.usePolling = false;
8482
8503
  }
8483
- const classNameStrategy = typeof testConfig.css !== "boolean" && ((_c = (_b = testConfig.css) == null ? void 0 : _b.modules) == null ? void 0 : _c.classNameStrategy) || "stable";
8504
+ const classNameStrategy = typeof testConfig.css !== "boolean" && ((_k = (_j = testConfig.css) == null ? void 0 : _j.modules) == null ? void 0 : _k.classNameStrategy) || "stable";
8484
8505
  if (classNameStrategy !== "scoped") {
8485
8506
  config.css ?? (config.css = {});
8486
- (_d = config.css).modules ?? (_d.modules = {});
8507
+ (_l = config.css).modules ?? (_l.modules = {});
8487
8508
  if (config.css.modules) {
8488
8509
  config.css.modules.generateScopedName = (name, filename) => {
8489
8510
  const root = getRoot();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.1.0",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -147,12 +147,12 @@
147
147
  "tinypool": "^0.8.1",
148
148
  "vite": "^5.0.0",
149
149
  "why-is-node-running": "^2.2.2",
150
- "@vitest/expect": "1.0.4",
151
- "@vitest/runner": "1.0.4",
152
- "@vitest/snapshot": "1.0.4",
153
- "@vitest/utils": "1.0.4",
154
- "@vitest/spy": "1.0.4",
155
- "vite-node": "1.0.4"
150
+ "@vitest/expect": "1.1.0",
151
+ "@vitest/snapshot": "1.1.0",
152
+ "@vitest/runner": "1.1.0",
153
+ "@vitest/spy": "1.1.0",
154
+ "@vitest/utils": "1.1.0",
155
+ "vite-node": "1.1.0"
156
156
  },
157
157
  "devDependencies": {
158
158
  "@ampproject/remapping": "^2.2.1",
@@ -164,7 +164,7 @@
164
164
  "@types/istanbul-reports": "^3.0.4",
165
165
  "@types/jsdom": "^21.1.6",
166
166
  "@types/micromatch": "^4.0.6",
167
- "@types/prompts": "^2.4.8",
167
+ "@types/prompts": "^2.4.9",
168
168
  "@types/sinonjs__fake-timers": "^8.1.5",
169
169
  "birpc": "0.2.14",
170
170
  "chai-subset": "^1.6.0",