vitest 1.0.4 → 1.1.1

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.
Files changed (36) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/child.js +3 -4
  4. package/dist/chunks/{integrations-globals.8mr2ENps.js → integrations-globals.nOa2-o57.js} +2 -2
  5. package/dist/cli.js +12 -4
  6. package/dist/config.cjs +1 -0
  7. package/dist/config.d.ts +25 -24
  8. package/dist/config.js +1 -0
  9. package/dist/coverage.d.ts +1 -1
  10. package/dist/entry-vm.js +2 -2
  11. package/dist/entry.js +2 -2
  12. package/dist/environments.d.ts +1 -1
  13. package/dist/environments.js +1 -2
  14. package/dist/execute.d.ts +10 -2
  15. package/dist/execute.js +1 -1
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +3 -3
  18. package/dist/node.d.ts +2 -2
  19. package/dist/node.js +3 -3
  20. package/dist/{reporters-OH1c16Kq.d.ts → reporters-O4LBziQ_.d.ts} +34 -1
  21. package/dist/reporters.d.ts +1 -1
  22. package/dist/reporters.js +1 -1
  23. package/dist/runners.d.ts +3 -4
  24. package/dist/runners.js +19 -14
  25. package/dist/{suite-9ReVEt_h.d.ts → suite-dF4WyktM.d.ts} +1 -1
  26. package/dist/suite.d.ts +2 -2
  27. package/dist/vendor/{environments.v4R4vGad.js → environments.QJtma9XQ.js} +6 -7
  28. package/dist/vendor/{execute.1R_t2FPL.js → execute.vStuEOaI.js} +30 -8
  29. package/dist/vendor/{index.uQelX_YY.js → index.n6c6aC2Y.js} +1 -1
  30. package/dist/vendor/{loader.zIj6SiI8.js → loader.L9CYwKn1.js} +1 -1
  31. package/dist/vendor/{node.vEetZgP7.js → node.d5m7SYoI.js} +109 -87
  32. package/dist/vendor/{reporters.r0gTYN3L.js → reporters.oUR9etwS.js} +12 -5
  33. package/dist/vendor/{vi.pk4NToBt.js → vi.ciwVQ0al.js} +7 -3
  34. package/dist/vm.js +3 -4
  35. package/dist/worker.js +3 -4
  36. package/package.json +8 -8
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/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('./chunks/integrations-globals.8mr2ENps.js')).registerApiGlobally();
16
+ (await import('./chunks/integrations-globals.nOa2-o57.js')).registerApiGlobally();
17
17
  }
18
18
  function setupDefines(defines) {
19
19
  for (const key in defines)
package/dist/child.js CHANGED
@@ -3,15 +3,14 @@ import v8 from 'node:v8';
3
3
  import { c as createBirpc } from './vendor/index.cAUulNDf.js';
4
4
  import { parseRegexp } from '@vitest/utils';
5
5
  import { workerId } from 'tinypool';
6
- import { l as loadEnvironment } from './vendor/loader.zIj6SiI8.js';
7
- import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.1R_t2FPL.js';
6
+ import { l as loadEnvironment } from './vendor/loader.L9CYwKn1.js';
7
+ import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor/execute.vStuEOaI.js';
8
8
  import { r as rpcDone, c as createSafeRpc } from './vendor/rpc.Bl-ysZIr.js';
9
9
  import { s as setupInspect } from './vendor/inspector.lFAeuaAt.js';
10
10
  import 'pathe';
11
11
  import 'vite-node/client';
12
- import './vendor/environments.v4R4vGad.js';
12
+ import './vendor/environments.QJtma9XQ.js';
13
13
  import 'node:console';
14
- import 'local-pkg';
15
14
  import 'node:url';
16
15
  import 'node:vm';
17
16
  import 'vite-node/utils';
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from '../vendor/constants.WSvnD_fn.js';
2
- import { i as index } from '../vendor/index.uQelX_YY.js';
2
+ import { i as index } from '../vendor/index.n6c6aC2Y.js';
3
3
  import '@vitest/runner';
4
4
  import '../vendor/benchmark.WVm6DARl.js';
5
5
  import '@vitest/runner/utils';
@@ -9,7 +9,7 @@ import 'pathe';
9
9
  import 'std-env';
10
10
  import '../vendor/global.L7JRz1qU.js';
11
11
  import '../vendor/run-once.X3E7xx3F.js';
12
- import '../vendor/vi.pk4NToBt.js';
12
+ import '../vendor/vi.ciwVQ0al.js';
13
13
  import 'chai';
14
14
  import '../vendor/_commonjsHelpers.jjO7Zipk.js';
15
15
  import '@vitest/expect';
package/dist/cli.js CHANGED
@@ -1,9 +1,9 @@
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.d5m7SYoI.js';
5
5
  import './vendor/index.XU72Rmy8.js';
6
- import { d as divider } from './vendor/reporters.r0gTYN3L.js';
6
+ import { d as divider } from './vendor/reporters.oUR9etwS.js';
7
7
  import { t as toArray } from './vendor/base._79unx2z.js';
8
8
  import 'vite';
9
9
  import 'node:path';
@@ -46,7 +46,7 @@ import 'node:crypto';
46
46
  import 'assert';
47
47
  import 'magic-string';
48
48
  import 'strip-literal';
49
- import './vendor/environments.v4R4vGad.js';
49
+ import './vendor/environments.QJtma9XQ.js';
50
50
  import 'node:console';
51
51
  import 'node:readline';
52
52
  import 'readline';
@@ -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';
package/dist/entry-vm.js CHANGED
@@ -8,7 +8,7 @@ import { setupColors, createColors } from '@vitest/utils';
8
8
  import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
9
9
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
10
10
  import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
11
- import { i as index } from './vendor/index.uQelX_YY.js';
11
+ import { i as index } from './vendor/index.n6c6aC2Y.js';
12
12
  import { setupCommonEnv } from './browser.js';
13
13
  import 'chai';
14
14
  import '@vitest/snapshot/environment';
@@ -21,7 +21,7 @@ import '@vitest/runner/utils';
21
21
  import './vendor/index.XU72Rmy8.js';
22
22
  import 'std-env';
23
23
  import './vendor/run-once.X3E7xx3F.js';
24
- import './vendor/vi.pk4NToBt.js';
24
+ import './vendor/vi.ciwVQ0al.js';
25
25
  import './vendor/_commonjsHelpers.jjO7Zipk.js';
26
26
  import '@vitest/expect';
27
27
  import '@vitest/snapshot';
package/dist/entry.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import './vendor/index.XU72Rmy8.js';
4
- import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.pk4NToBt.js';
4
+ import { a as globalExpect, r as resetModules, v as vi } from './vendor/vi.ciwVQ0al.js';
5
5
  import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor/coverage.v6aD8iAh.js';
6
6
  import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor/index.h0j9y5vy.js';
7
7
  import { createRequire } from 'node:module';
@@ -10,7 +10,7 @@ import timers from 'node:timers';
10
10
  import { isatty } from 'node:tty';
11
11
  import { installSourcemapsSupport } from 'vite-node/source-map';
12
12
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
13
- import { i as index } from './vendor/index.uQelX_YY.js';
13
+ import { i as index } from './vendor/index.n6c6aC2Y.js';
14
14
  import { setupCommonEnv } from './browser.js';
15
15
  import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
16
16
  import 'pathe';
@@ -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';
@@ -1,3 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor/environments.v4R4vGad.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor/environments.QJtma9XQ.js';
2
2
  import 'node:console';
3
- import 'local-pkg';
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';
@@ -16,6 +16,12 @@ import 'node:fs';
16
16
  import 'chai';
17
17
 
18
18
  type Key = string | symbol;
19
+ interface MockContext {
20
+ /**
21
+ * When mocking with a factory, this refers to the module that imported the mock.
22
+ */
23
+ callstack: null | string[];
24
+ }
19
25
  declare class VitestMocker {
20
26
  executor: VitestExecutor;
21
27
  static pendingIds: PendingSuiteMock[];
@@ -23,6 +29,7 @@ declare class VitestMocker {
23
29
  private resolveCache;
24
30
  private primitives;
25
31
  private filterPublicKeys;
32
+ private mockContext;
26
33
  constructor(executor: VitestExecutor);
27
34
  private get root();
28
35
  private get mockMap();
@@ -39,6 +46,7 @@ declare class VitestMocker {
39
46
  private resolvePath;
40
47
  resolveMocks(): Promise<void>;
41
48
  private callFunctionMock;
49
+ getMockContext(): MockContext;
42
50
  getMockPath(dep: string): string;
43
51
  getDependencyMock(id: string): string | MockFactory | null;
44
52
  normalizePath(path: string): string;
@@ -46,7 +54,7 @@ declare class VitestMocker {
46
54
  mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
47
55
  unmockPath(path: string): void;
48
56
  mockPath(originalId: string, path: string, external: string | null, factory?: MockFactory): void;
49
- importActual<T>(rawId: string, importee: string): Promise<T>;
57
+ importActual<T>(rawId: string, importer: string, callstack?: string[] | null): Promise<T>;
50
58
  importMock(rawId: string, importee: string): Promise<any>;
51
59
  requestWithMock(url: string, callstack: string[]): Promise<any>;
52
60
  queueMock(id: string, importer: string, factory?: MockFactory): void;
package/dist/execute.js CHANGED
@@ -1,4 +1,4 @@
1
- export { V as VitestExecutor } from './vendor/execute.1R_t2FPL.js';
1
+ export { V as VitestExecutor } from './vendor/execute.vStuEOaI.js';
2
2
  import 'node:url';
3
3
  import 'node:vm';
4
4
  import 'vite-node/client';
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/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
2
  export { b as bench } from './vendor/benchmark.WVm6DARl.js';
3
3
  export { i as isFirstRun, r as runOnce } from './vendor/run-once.X3E7xx3F.js';
4
- export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.pk4NToBt.js';
5
- import { d as dist } from './vendor/index.uQelX_YY.js';
6
- export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.uQelX_YY.js';
4
+ export { c as createExpect, a as expect, v as vi, b as vitest } from './vendor/vi.ciwVQ0al.js';
5
+ import { d as dist } from './vendor/index.n6c6aC2Y.js';
6
+ export { c as assertType, g as getRunningMode, a as inject, b as isWatchMode } from './vendor/index.n6c6aC2Y.js';
7
7
  import * as chai from 'chai';
8
8
  export { chai };
9
9
  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, 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.d5m7SYoI.js';
2
2
  import 'pathe';
3
3
  import 'vite';
4
4
  import 'node:path';
@@ -41,7 +41,7 @@ import 'node:module';
41
41
  import 'local-pkg';
42
42
  import 'module';
43
43
  import 'acorn-walk';
44
- import './vendor/reporters.r0gTYN3L.js';
44
+ import './vendor/reporters.oUR9etwS.js';
45
45
  import './chunks/runtime-console.hf2msWA9.js';
46
46
  import 'node:stream';
47
47
  import 'node:console';
@@ -51,6 +51,6 @@ import 'node:crypto';
51
51
  import 'assert';
52
52
  import 'magic-string';
53
53
  import 'strip-literal';
54
- import './vendor/environments.v4R4vGad.js';
54
+ import './vendor/environments.QJtma9XQ.js';
55
55
  import 'node:readline';
56
56
  import 'readline';
@@ -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/reporters.js CHANGED
@@ -1,4 +1,4 @@
1
- export { e as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, f as DotReporter, H as HangingProcessReporter, g as JUnitReporter, J as JsonReporter, R as ReportersMap, h as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/reporters.r0gTYN3L.js';
1
+ export { e as BasicReporter, B as BenchmarkReportsMap, D as DefaultReporter, f as DotReporter, H as HangingProcessReporter, g as JUnitReporter, J as JsonReporter, R as ReportersMap, h as TapFlatReporter, T as TapReporter, V as VerboseReporter } from './vendor/reporters.oUR9etwS.js';
2
2
  import 'node:perf_hooks';
3
3
  import 'picocolors';
4
4
  import './vendor/index.XU72Rmy8.js';
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';
@@ -23,12 +23,11 @@ declare class VitestTestRunner implements VitestRunner {
23
23
  constructor(config: ResolvedConfig);
24
24
  importFile(filepath: string, source: VitestRunnerImportSource): unknown;
25
25
  onBeforeRunFiles(): void;
26
- onAfterRunFiles(): Promise<void>;
27
- onAfterRunSuite(suite: Suite): void;
26
+ onAfterRunSuite(suite: Suite): Promise<void>;
28
27
  onAfterRunTask(test: Test): void;
29
28
  onCancel(_reason: CancelReason): void;
30
29
  onBeforeRunTask(test: Test): Promise<void>;
31
- onBeforeRunSuite(suite: Suite): void;
30
+ onBeforeRunSuite(suite: Suite): Promise<void>;
32
31
  onBeforeTryTask(test: Test): void;
33
32
  onAfterTryTask(test: Test): void;
34
33
  extendTaskContext<T extends Test | Custom>(context: TaskContext<T>): ExtendedContext<T>;
package/dist/runners.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.pk4NToBt.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi } from './vendor/vi.ciwVQ0al.js';
3
3
  import './vendor/index.XU72Rmy8.js';
4
4
  import { a as rpc } from './vendor/rpc.Bl-ysZIr.js';
5
5
  import { g as getFullName } from './vendor/tasks.IknbGB2n.js';
6
6
  import { g as getWorkerState } from './vendor/global.L7JRz1qU.js';
7
- import { getNames } from '@vitest/runner/utils';
7
+ import { getTests, getNames } from '@vitest/runner/utils';
8
8
  import { updateTask } from '@vitest/runner';
9
9
  import { createDefer, getSafeTimers } from '@vitest/utils';
10
10
  import { a as getBenchOptions, g as getBenchFn } from './vendor/benchmark.WVm6DARl.js';
@@ -34,14 +34,20 @@ class VitestTestRunner {
34
34
  onBeforeRunFiles() {
35
35
  this.snapshotClient.clear();
36
36
  }
37
- async onAfterRunFiles() {
38
- const result = await this.snapshotClient.finishCurrentRun();
39
- if (result)
40
- await rpc().snapshotSaved(result);
41
- }
42
- onAfterRunSuite(suite) {
37
+ async onAfterRunSuite(suite) {
43
38
  if (this.config.logHeapUsage && typeof process !== "undefined")
44
39
  suite.result.heap = process.memoryUsage().heapUsed;
40
+ if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
41
+ for (const test of getTests(suite)) {
42
+ if (test.mode === "skip") {
43
+ const name = getNames(test).slice(1).join(" > ");
44
+ this.snapshotClient.skipTestSnapshots(name);
45
+ }
46
+ }
47
+ const result = await this.snapshotClient.finishCurrentRun();
48
+ if (result)
49
+ await rpc().snapshotSaved(result);
50
+ }
45
51
  }
46
52
  onAfterRunTask(test) {
47
53
  this.snapshotClient.clearTest();
@@ -53,20 +59,19 @@ class VitestTestRunner {
53
59
  this.cancelRun = true;
54
60
  }
55
61
  async onBeforeRunTask(test) {
56
- const name = getNames(test).slice(1).join(" > ");
57
62
  if (this.cancelRun)
58
63
  test.mode = "skip";
59
- if (test.mode !== "run") {
60
- this.snapshotClient.skipTestSnapshots(name);
64
+ if (test.mode !== "run")
61
65
  return;
62
- }
63
66
  clearModuleMocks(this.config);
64
- await this.snapshotClient.startCurrentRun(test.file.filepath, name, this.workerState.config.snapshotOptions);
65
67
  this.workerState.current = test;
66
68
  }
67
- onBeforeRunSuite(suite) {
69
+ async onBeforeRunSuite(suite) {
68
70
  if (this.cancelRun)
69
71
  suite.mode = "skip";
72
+ if (suite.mode !== "skip" && typeof suite.filepath !== "undefined") {
73
+ await this.snapshotClient.startCurrentRun(suite.filepath, "__default_name_", this.workerState.config.snapshotOptions);
74
+ }
70
75
  }
71
76
  onBeforeTryTask(test) {
72
77
  var _a;
@@ -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';