vitest 0.31.4 → 0.32.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.
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { startTests } from '@vitest/runner';
2
- import { a as ResolvedConfig, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule } from './types-dea83b3d.js';
2
+ import { a as ResolvedConfig, a0 as CoverageOptions, Y as CoverageProvider, _ as CoverageProviderModule } from './types-2b1c412e.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';
package/dist/browser.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { startTests } from '@vitest/runner';
2
- export { s as setupCommonEnv } from './vendor-setup.common.823a1300.js';
3
- export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor-coverage.c8fd34c3.js';
2
+ export { s as setupCommonEnv } from './vendor-setup.common.f1cf2231.js';
3
+ export { g as getCoverageProvider, a as startCoverageInsideWorker, s as stopCoverageInsideWorker, t as takeCoverageInsideWorker } from './vendor-coverage.de2180ed.js';
4
4
  import '@vitest/utils';
5
5
  import './vendor-run-once.69ce7172.js';
6
6
  import './vendor-index.fad2598b.js';
package/dist/child.js CHANGED
@@ -1,14 +1,15 @@
1
+ import { performance } from 'node:perf_hooks';
1
2
  import v8 from 'node:v8';
2
- import { c as createBirpc } from './vendor-index.5037f2c0.js';
3
+ import { c as createBirpc } from './vendor-index.87ab04c3.js';
3
4
  import { parseRegexp } from '@vitest/utils';
4
- import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.132a3e09.js';
5
+ import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.001ae440.js';
5
6
  import { a as rpcDone } from './vendor-rpc.4d3d7a54.js';
6
7
  import { s as setupInspect } from './vendor-inspector.47fc8cbb.js';
7
8
  import 'node:url';
8
9
  import 'vite-node/client';
9
10
  import 'vite-node/utils';
10
11
  import 'pathe';
11
- import '@vitest/runner/utils';
12
+ import '@vitest/utils/error';
12
13
  import './vendor-global.6795f91f.js';
13
14
  import './vendor-paths.84fc7a99.js';
14
15
  import 'node:fs';
@@ -1,6 +1,6 @@
1
1
  import { promises, existsSync } from 'node:fs';
2
2
  import { dirname } from 'pathe';
3
- import { c as createBirpc, i as isPrimitive } from './vendor-index.5037f2c0.js';
3
+ import { c as createBirpc, i as isPrimitive } from './vendor-index.87ab04c3.js';
4
4
  import require$$0$2 from 'stream';
5
5
  import require$$0 from 'zlib';
6
6
  import require$$0$1 from 'buffer';
@@ -3,7 +3,7 @@ import p from 'path';
3
3
  import require$$0$1 from 'util';
4
4
  import require$$0$3 from 'child_process';
5
5
  import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.c1e09929.js';
6
- import { o as onetime$1 } from './vendor-cli-api.8cf937e8.js';
6
+ import { o as onetime$1 } from './vendor-cli-api.17011d0a.js';
7
7
  import require$$0$2 from 'os';
8
8
  import 'node:buffer';
9
9
  import 'node:path';
@@ -20,7 +20,7 @@ import 'stream';
20
20
  import 'node:util';
21
21
  import 'pathe';
22
22
  import './vendor-constants.538d9b49.js';
23
- import './vendor-coverage.c8fd34c3.js';
23
+ import './vendor-coverage.de2180ed.js';
24
24
  import './vendor-index.75f2b63d.js';
25
25
  import 'node:console';
26
26
  import 'local-pkg';
@@ -37,7 +37,7 @@ import '@vitest/snapshot/manager';
37
37
  import 'vite-node/server';
38
38
  import './vendor-paths.84fc7a99.js';
39
39
  import 'node:v8';
40
- import './vendor-index.5037f2c0.js';
40
+ import './vendor-index.87ab04c3.js';
41
41
  import 'node:worker_threads';
42
42
  import 'tinypool';
43
43
  import 'node:perf_hooks';
@@ -1,7 +1,7 @@
1
1
  import { g as globalApis } from './vendor-constants.538d9b49.js';
2
- import { i as index } from './vendor-index.f81f6285.js';
2
+ import { i as index } from './vendor-index.0f133dbe.js';
3
3
  import '@vitest/runner';
4
- import './vendor-vi.23b98fa1.js';
4
+ import './vendor-vi.74cf3ef7.js';
5
5
  import '@vitest/runner/utils';
6
6
  import '@vitest/utils';
7
7
  import './vendor-index.fad2598b.js';
@@ -12,6 +12,7 @@ import 'chai';
12
12
  import './vendor-_commonjsHelpers.76cdd49e.js';
13
13
  import '@vitest/expect';
14
14
  import '@vitest/snapshot';
15
+ import '@vitest/utils/error';
15
16
  import './vendor-tasks.f9d75aed.js';
16
17
  import 'util';
17
18
  import '@vitest/spy';
package/dist/cli.js CHANGED
@@ -1,18 +1,16 @@
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, d as divider } from './vendor-cli-api.8cf937e8.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.17011d0a.js';
5
+ import './vendor-index.fad2598b.js';
6
+ import { t as toArray } from './vendor-index.87ab04c3.js';
5
7
  import './vendor-constants.538d9b49.js';
6
- import './vendor-coverage.c8fd34c3.js';
8
+ import './vendor-coverage.de2180ed.js';
7
9
  import './vendor-index.75f2b63d.js';
8
10
  import 'node:console';
9
11
  import 'local-pkg';
10
12
  import 'node:url';
11
- import './vendor-index.fad2598b.js';
12
13
  import 'std-env';
13
- import '@vitest/runner/utils';
14
- import '@vitest/utils';
15
- import './vendor-global.6795f91f.js';
16
14
  import 'vite';
17
15
  import 'node:path';
18
16
  import 'node:process';
@@ -31,12 +29,13 @@ import 'vite-node/server';
31
29
  import './vendor-paths.84fc7a99.js';
32
30
  import 'node:v8';
33
31
  import 'node:child_process';
34
- import './vendor-index.5037f2c0.js';
35
32
  import 'node:worker_threads';
36
33
  import 'node:os';
37
34
  import 'tinypool';
35
+ import '@vitest/utils';
38
36
  import 'node:perf_hooks';
39
37
  import './vendor-tasks.f9d75aed.js';
38
+ import '@vitest/runner/utils';
40
39
  import 'node:module';
41
40
  import 'node:crypto';
42
41
  import './vendor-index.c1e09929.js';
@@ -53,6 +52,7 @@ import 'magic-string';
53
52
  import 'strip-literal';
54
53
  import 'node:readline';
55
54
  import 'readline';
55
+ import './vendor-global.6795f91f.js';
56
56
 
57
57
  const cli = cac("vitest");
58
58
  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("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--isolate", "Isolate environment for each test file (default: true)").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("--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("--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)").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 }).help();
@@ -114,6 +114,17 @@ function normalizeCliOptions(argv) {
114
114
  argv.dir = normalize(argv.dir);
115
115
  else
116
116
  delete argv.dir;
117
+ if (argv.coverage) {
118
+ const coverage = argv.coverage;
119
+ if (coverage.exclude)
120
+ coverage.exclude = toArray(coverage.exclude);
121
+ if (coverage.include)
122
+ coverage.include = toArray(coverage.include);
123
+ if (coverage.ignoreClassMethods)
124
+ coverage.ignoreClassMethods = toArray(coverage.ignoreClassMethods);
125
+ if (coverage.src)
126
+ coverage.src = toArray(coverage.src);
127
+ }
117
128
  return argv;
118
129
  }
119
130
  async function start(mode, cliFilters, options) {
package/dist/config.cjs CHANGED
@@ -6,24 +6,23 @@ var vite = require('vite');
6
6
  var _a;
7
7
  typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
8
8
 
9
- const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
9
+ const defaultInclude = ["**/__tests__/**/*.?(c|m)[jt]s?(x)", "**/?(*.){test,spec}.?(c|m)[jt]s?(x)"];
10
10
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
11
11
  const defaultCoverageExcludes = [
12
12
  "coverage/**",
13
13
  "dist/**",
14
- "packages/*/test{,s}/**",
14
+ "packages/*/test?(s)/**",
15
15
  "**/*.d.ts",
16
16
  "cypress/**",
17
- "test{,s}/**",
18
- "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
19
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
20
- "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
17
+ "test?(s)/**",
18
+ "test?(-*).?(c|m)[jt]s?(x)",
19
+ "**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)",
21
20
  "**/__tests__/**",
22
21
  "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
23
- "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
22
+ "**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
24
23
  ];
25
24
  const coverageConfigDefaults = {
26
- provider: "c8",
25
+ provider: "v8",
27
26
  enabled: false,
28
27
  clean: true,
29
28
  cleanOnRerun: true,
@@ -85,7 +84,7 @@ const config = {
85
84
  dangerouslyIgnoreUnhandledErrors: false,
86
85
  typecheck: {
87
86
  checker: "tsc",
88
- include: ["**/*.{test,spec}-d.{ts,js}"],
87
+ include: ["**/?(*.){test,spec}-d.?(c|m)[jt]s?(x)"],
89
88
  exclude: defaultExclude
90
89
  },
91
90
  slowTestThreshold: 300
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
- import { a0 as ResolvedCoverageOptions, q as UserConfig, a3 as CoverageC8Options, a4 as CustomProviderOptions, a2 as CoverageIstanbulOptions, ag as HtmlOptions, ah as FileOptions, ai as CloverOptions, aj as CoberturaOptions, ak as HtmlSpaOptions, al as LcovOptions, am as LcovOnlyOptions, an as TeamcityOptions, ao as TextOptions, ap as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-dea83b3d.js';
3
+ import { a1 as ResolvedCoverageOptions, q as UserConfig, a5 as CoverageV8Options, a4 as CoverageC8Options, a6 as CustomProviderOptions, a3 as CoverageIstanbulOptions, aj as HtmlOptions, ak as FileOptions, al as CloverOptions, am as CoberturaOptions, an as HtmlSpaOptions, ao as LcovOptions, ap as LcovOnlyOptions, aq as TeamcityOptions, ar as TextOptions, as as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-2b1c412e.js';
4
4
  import '@vitest/snapshot';
5
5
  import '@vitest/expect';
6
6
  import '@vitest/runner';
@@ -47,14 +47,16 @@ declare const config: {
47
47
  include: never[];
48
48
  };
49
49
  coverage: {
50
- provider: "c8";
51
- } & CoverageC8Options & Required<Pick<({
50
+ provider: "v8";
51
+ } & CoverageV8Options & Required<Pick<({
52
52
  provider?: undefined;
53
53
  } & CoverageC8Options) | ({
54
54
  provider: "custom";
55
55
  } & CustomProviderOptions) | ({
56
56
  provider: "c8";
57
57
  } & CoverageC8Options) | ({
58
+ provider: "v8";
59
+ } & CoverageV8Options) | ({
58
60
  provider: "istanbul";
59
61
  } & CoverageIstanbulOptions), "exclude" | "enabled" | "clean" | "cleanOnRerun" | "reportsDirectory" | "extension" | "reportOnFailure">> & {
60
62
  reporter: (["html", Partial<HtmlOptions>] | ["none", {}] | ["json", Partial<FileOptions>] | ["clover", Partial<CloverOptions>] | ["cobertura", Partial<CoberturaOptions>] | ["html-spa", Partial<HtmlSpaOptions>] | ["json-summary", Partial<FileOptions>] | ["lcov", Partial<LcovOptions>] | ["lcovonly", Partial<LcovOnlyOptions>] | ["teamcity", Partial<TeamcityOptions>] | ["text", Partial<TextOptions>] | ["text-lcov", Partial<ProjectOptions>] | ["text-summary", Partial<FileOptions>])[];
package/dist/config.js CHANGED
@@ -4,24 +4,23 @@ export { mergeConfig } from 'vite';
4
4
  var _a;
5
5
  typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
6
6
 
7
- const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
7
+ const defaultInclude = ["**/__tests__/**/*.?(c|m)[jt]s?(x)", "**/?(*.){test,spec}.?(c|m)[jt]s?(x)"];
8
8
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
9
9
  const defaultCoverageExcludes = [
10
10
  "coverage/**",
11
11
  "dist/**",
12
- "packages/*/test{,s}/**",
12
+ "packages/*/test?(s)/**",
13
13
  "**/*.d.ts",
14
14
  "cypress/**",
15
- "test{,s}/**",
16
- "test{,-*}.{js,cjs,mjs,ts,tsx,jsx}",
17
- "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
18
- "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
15
+ "test?(s)/**",
16
+ "test?(-*).?(c|m)[jt]s?(x)",
17
+ "**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)",
19
18
  "**/__tests__/**",
20
19
  "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
21
- "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
20
+ "**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
22
21
  ];
23
22
  const coverageConfigDefaults = {
24
- provider: "c8",
23
+ provider: "v8",
25
24
  enabled: false,
26
25
  clean: true,
27
26
  cleanOnRerun: true,
@@ -83,7 +82,7 @@ const config = {
83
82
  dangerouslyIgnoreUnhandledErrors: false,
84
83
  typecheck: {
85
84
  checker: "tsc",
86
- include: ["**/*.{test,spec}-d.{ts,js}"],
85
+ include: ["**/?(*.){test,spec}-d.?(c|m)[jt]s?(x)"],
87
86
  exclude: defaultExclude
88
87
  },
89
88
  slowTestThreshold: 300
@@ -1,4 +1,4 @@
1
- import { a1 as BaseCoverageOptions, a0 as ResolvedCoverageOptions } from './types-dea83b3d.js';
1
+ import { a2 as BaseCoverageOptions, a1 as ResolvedCoverageOptions } from './types-2b1c412e.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
@@ -135,6 +135,14 @@ declare class BaseCoverageProvider {
135
135
  perFile?: boolean;
136
136
  configurationFile?: string;
137
137
  }): void;
138
+ /**
139
+ * Checked collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
140
+ */
141
+ checkThresholds({ coverageMap, thresholds, perFile }: {
142
+ coverageMap: CoverageMap;
143
+ thresholds: Record<Threshold, number | undefined>;
144
+ perFile?: boolean;
145
+ }): void;
138
146
  /**
139
147
  * Resolve reporters from various configuration options
140
148
  */
package/dist/coverage.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { relative } from 'pathe';
2
3
 
3
4
  const THRESHOLD_KEYS = ["lines", "functions", "statements", "branches"];
4
5
  class BaseCoverageProvider {
@@ -34,6 +35,36 @@ class BaseCoverageProvider {
34
35
  writeFileSync(configurationFile, updatedConfig, "utf-8");
35
36
  }
36
37
  }
38
+ /**
39
+ * Checked collected coverage against configured thresholds. Sets exit code to 1 when thresholds not reached.
40
+ */
41
+ checkThresholds({ coverageMap, thresholds, perFile }) {
42
+ const summaries = perFile ? coverageMap.files().map((file) => ({
43
+ file,
44
+ summary: coverageMap.fileCoverageFor(file).toSummary()
45
+ })) : [{
46
+ file: null,
47
+ summary: coverageMap.getCoverageSummary()
48
+ }];
49
+ for (const { summary, file } of summaries) {
50
+ for (const thresholdKey of ["lines", "functions", "statements", "branches"]) {
51
+ const threshold = thresholds[thresholdKey];
52
+ if (threshold !== void 0) {
53
+ const coverage = summary.data[thresholdKey].pct;
54
+ if (coverage < threshold) {
55
+ process.exitCode = 1;
56
+ let errorMessage = `ERROR: Coverage for ${thresholdKey} (${coverage}%) does not meet`;
57
+ if (!perFile)
58
+ errorMessage += " global";
59
+ errorMessage += ` threshold (${threshold}%)`;
60
+ if (perFile && file)
61
+ errorMessage += ` for ${relative("./", file).replace(/\\/g, "/")}`;
62
+ console.error(errorMessage);
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
37
68
  /**
38
69
  * Resolve reporters from various configuration options
39
70
  */
package/dist/entry.js CHANGED
@@ -2,9 +2,9 @@ import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import { resolve } from 'pathe';
4
4
  import { c as resetModules } from './vendor-index.fad2598b.js';
5
- import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.23b98fa1.js';
5
+ import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.74cf3ef7.js';
6
6
  import { d as distDir } from './vendor-paths.84fc7a99.js';
7
- import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.c8fd34c3.js';
7
+ import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.de2180ed.js';
8
8
  import { createRequire } from 'node:module';
9
9
  import { isatty } from 'node:tty';
10
10
  import { installSourcemapsSupport } from 'vite-node/source-map';
@@ -12,8 +12,8 @@ import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
12
12
  import { e as environments } from './vendor-index.75f2b63d.js';
13
13
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
14
14
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
15
- import { i as index } from './vendor-index.f81f6285.js';
16
- import { s as setupCommonEnv } from './vendor-setup.common.823a1300.js';
15
+ import { i as index } from './vendor-index.0f133dbe.js';
16
+ import { s as setupCommonEnv } from './vendor-setup.common.f1cf2231.js';
17
17
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
18
18
  import 'std-env';
19
19
  import '@vitest/runner/utils';
@@ -21,6 +21,7 @@ import 'chai';
21
21
  import './vendor-_commonjsHelpers.76cdd49e.js';
22
22
  import '@vitest/expect';
23
23
  import '@vitest/snapshot';
24
+ import '@vitest/utils/error';
24
25
  import './vendor-tasks.f9d75aed.js';
25
26
  import 'util';
26
27
  import '@vitest/spy';
@@ -1,4 +1,4 @@
1
- import { Q as Environment } from './types-dea83b3d.js';
1
+ import { S as Environment } from './types-2b1c412e.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { File, TaskResultPack, CancelReason } from '@vitest/runner';
2
2
  export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-dea83b3d.js';
4
- export { n as ApiConfig, G as ArgumentsType, D as Arrayable, z as Awaitable, a1 as BaseCoverageOptions, a8 as BenchFunction, a6 as Benchmark, a7 as BenchmarkResult, a5 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, K as Constructable, j as Context, v as ContextRPC, u as ContextTestEnvironment, a3 as CoverageC8Options, a2 as CoverageIstanbulOptions, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule, _ as CoverageReporter, a4 as CustomProviderOptions, Q as Environment, E as EnvironmentOptions, O as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, L as ModuleCache, H as MutableArray, N as Nullable, S as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, Y as ReportContext, x as ResolveIdFunction, a0 as ResolvedCoverageOptions, i as RootAndTarget, t as RunnerRPC, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, w as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, y as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-dea83b3d.js';
3
+ import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-2b1c412e.js';
4
+ export { n as ApiConfig, H as ArgumentsType, G as Arrayable, z as Awaitable, a2 as BaseCoverageOptions, aa as BenchFunction, a8 as Benchmark, a9 as BenchmarkResult, a7 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, L as Constructable, j as Context, v as ContextRPC, u as ContextTestEnvironment, a4 as CoverageC8Options, a3 as CoverageIstanbulOptions, a0 as CoverageOptions, Y as CoverageProvider, _ as CoverageProviderModule, $ as CoverageReporter, a5 as CoverageV8Options, a6 as CustomProviderOptions, D as DepsOptimizationOptions, S as Environment, E as EnvironmentOptions, Q as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, O as ModuleCache, K as MutableArray, N as Nullable, X as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, Z as ReportContext, x as ResolveIdFunction, a1 as ResolvedCoverageOptions, i as RootAndTarget, t as RunnerRPC, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, w as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, y as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-2b1c412e.js';
5
5
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
6
6
  export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
7
7
  export { SnapshotEnvironment } from '@vitest/snapshot/environment';
@@ -13,9 +13,9 @@ import * as chai from 'chai';
13
13
  export { chai };
14
14
  export { assert, should } from 'chai';
15
15
  export { UserWorkspaceConfig } from './config.js';
16
- export { ErrorWithDiff, ParsedStack } from '@vitest/runner/utils';
16
+ export { ErrorWithDiff, ParsedStack } from '@vitest/utils';
17
17
  export { Bench as BenchFactory, Options as BenchOptions, Task as BenchTask, TaskResult as BenchTaskResult } from 'tinybench';
18
- import '@vitest/utils';
18
+ import '@vitest/runner/utils';
19
19
  import 'vite-node/client';
20
20
  import '@vitest/snapshot/manager';
21
21
  import 'vite-node/server';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.23b98fa1.js';
2
+ export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.74cf3ef7.js';
3
3
  export { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
- import { d as dist } from './vendor-index.f81f6285.js';
5
- export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.f81f6285.js';
4
+ import { d as dist } from './vendor-index.0f133dbe.js';
5
+ export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.0f133dbe.js';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
@@ -15,6 +15,7 @@ import './vendor-global.6795f91f.js';
15
15
  import './vendor-_commonjsHelpers.76cdd49e.js';
16
16
  import '@vitest/expect';
17
17
  import '@vitest/snapshot';
18
+ import '@vitest/utils/error';
18
19
  import './vendor-tasks.f9d75aed.js';
19
20
  import 'util';
20
21
  import '@vitest/spy';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as VitestRunMode, q as UserConfig, w as Vitest, a9 as MockFactory, aa as MockMap, ab as TestSequencer, ac as WorkspaceSpec } from './types-dea83b3d.js';
2
- export { af as TestSequencerConstructor, ad as VitestWorkspace, ae as startVitest } from './types-dea83b3d.js';
1
+ import { o as VitestRunMode, q as UserConfig, w as Vitest, ab as PendingSuiteMock, ac as MockFactory, ad as MockMap, ae as TestSequencer, af as WorkspaceSpec } from './types-2b1c412e.js';
2
+ export { ai as TestSequencerConstructor, ag as VitestWorkspace, ah as startVitest } from './types-2b1c412e.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
@@ -19,10 +19,12 @@ declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOver
19
19
 
20
20
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
21
21
 
22
+ declare function registerConsoleShortcuts(ctx: Vitest): void;
23
+
22
24
  type Key = string | symbol;
23
25
  declare class VitestMocker {
24
26
  executor: VitestExecutor;
25
- private static pendingIds;
27
+ static pendingIds: PendingSuiteMock[];
26
28
  private resolveCache;
27
29
  constructor(executor: VitestExecutor);
28
30
  private get root();
@@ -36,7 +38,7 @@ declare class VitestMocker {
36
38
  [x: string]: string | MockFactory | null;
37
39
  };
38
40
  private resolvePath;
39
- private resolveMocks;
41
+ resolveMocks(): Promise<void>;
40
42
  private callFunctionMock;
41
43
  getMockPath(dep: string): string;
42
44
  getDependencyMock(id: string): string | MockFactory | null;
@@ -61,7 +63,8 @@ declare class VitestExecutor extends ViteNodeRunner {
61
63
  mocker: VitestMocker;
62
64
  constructor(options: ExecuteOptions);
63
65
  shouldResolveId(id: string, _importee?: string | undefined): boolean;
64
- resolveUrl(id: string, importer?: string): Promise<[url: string, fsPath: string]>;
66
+ originalResolveUrl(id: string, importer?: string): Promise<[url: string, fsPath: string]>;
67
+ resolveUrl(id: string, importer?: string): Promise<[string, string]>;
65
68
  dependencyRequest(id: string, fsPath: string, callstack: string[]): Promise<any>;
66
69
  prepareContext(context: Record<string, any>): Record<string, any>;
67
70
  }
@@ -73,4 +76,4 @@ declare class BaseSequencer implements TestSequencer {
73
76
  sort(files: WorkspaceSpec[]): Promise<WorkspaceSpec[]>;
74
77
  }
75
78
 
76
- export { BaseSequencer, ExecuteOptions, TestSequencer, Vitest, VitestExecutor, VitestPlugin, WorkspaceSpec, createVitest };
79
+ export { BaseSequencer, ExecuteOptions, TestSequencer, Vitest, VitestExecutor, VitestPlugin, WorkspaceSpec, createVitest, registerConsoleShortcuts };
package/dist/node.js CHANGED
@@ -1,8 +1,8 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.8cf937e8.js';
2
- export { V as VitestExecutor } from './vendor-execute.132a3e09.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-cli-api.17011d0a.js';
2
+ export { V as VitestExecutor } from './vendor-execute.001ae440.js';
3
3
  import 'pathe';
4
4
  import './vendor-constants.538d9b49.js';
5
- import './vendor-coverage.c8fd34c3.js';
5
+ import './vendor-coverage.de2180ed.js';
6
6
  import './vendor-index.75f2b63d.js';
7
7
  import 'node:console';
8
8
  import 'local-pkg';
@@ -31,7 +31,7 @@ import 'vite-node/server';
31
31
  import './vendor-paths.84fc7a99.js';
32
32
  import 'node:v8';
33
33
  import 'node:child_process';
34
- import './vendor-index.5037f2c0.js';
34
+ import './vendor-index.87ab04c3.js';
35
35
  import 'node:worker_threads';
36
36
  import 'node:os';
37
37
  import 'tinypool';
@@ -53,5 +53,6 @@ import 'magic-string';
53
53
  import 'strip-literal';
54
54
  import 'node:readline';
55
55
  import 'readline';
56
+ import '@vitest/utils/error';
56
57
  import '@vitest/spy';
57
58
  import './vendor-rpc.4d3d7a54.js';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
- import { a as ResolvedConfig } from './types-dea83b3d.js';
2
+ import { a as ResolvedConfig } from './types-2b1c412e.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';
package/dist/runners.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect';
2
- import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.23b98fa1.js';
2
+ import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.74cf3ef7.js';
3
3
  import './vendor-index.fad2598b.js';
4
4
  import { r as rpc } from './vendor-rpc.4d3d7a54.js';
5
5
  import { g as getFullName } from './vendor-tasks.f9d75aed.js';
@@ -11,6 +11,7 @@ import { createDefer, getSafeTimers } from '@vitest/utils';
11
11
  import 'chai';
12
12
  import './vendor-_commonjsHelpers.76cdd49e.js';
13
13
  import '@vitest/snapshot';
14
+ import '@vitest/utils/error';
14
15
  import 'util';
15
16
  import '@vitest/spy';
16
17
  import 'pathe';
@@ -1,10 +1,10 @@
1
1
  import { SnapshotResult, SnapshotStateOptions, SnapshotState } from '@vitest/snapshot';
2
2
  import { ExpectStatic } from '@vitest/expect';
3
- import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, CommonServerOptions, AliasOptions, DepOptimizationConfig } from 'vite';
3
+ import { ViteDevServer, UserConfig as UserConfig$1, TransformResult as TransformResult$1, CommonServerOptions, DepOptimizationConfig, AliasOptions } from 'vite';
4
4
  import * as _vitest_runner from '@vitest/runner';
5
5
  import { File, Test as Test$1, Suite, TaskResultPack, Task, CancelReason, TaskCustom, SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
6
- import { ParsedStack, ErrorWithDiff, ChainableFunction } from '@vitest/runner/utils';
7
- import { Awaitable as Awaitable$1, Arrayable as Arrayable$1 } from '@vitest/utils';
6
+ import { ChainableFunction } from '@vitest/runner/utils';
7
+ import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, Arrayable as Arrayable$1 } from '@vitest/utils';
8
8
  import { Task as Task$1, TaskResult, Bench, Options } from 'tinybench';
9
9
  import { ViteNodeRunner } from 'vite-node/client';
10
10
  import { SnapshotManager } from '@vitest/snapshot/manager';
@@ -535,6 +535,12 @@ declare class Vitest {
535
535
  type MockFactoryWithHelper = (importOriginal: <T = unknown>() => Promise<T>) => any;
536
536
  type MockFactory = () => any;
537
537
  type MockMap = Map<string, Record<string, string | null | MockFactory>>;
538
+ interface PendingSuiteMock {
539
+ id: string;
540
+ importer: string;
541
+ type: 'mock' | 'unmock';
542
+ factory?: MockFactory;
543
+ }
538
544
 
539
545
  interface TestSequencer {
540
546
  /**
@@ -978,12 +984,14 @@ interface CoverageProviderModule {
978
984
  }
979
985
  type CoverageReporter = keyof ReportOptions;
980
986
  type CoverageReporterWithOptions<ReporterName extends CoverageReporter = CoverageReporter> = ReporterName extends CoverageReporter ? ReportOptions[ReporterName] extends never ? [ReporterName, {}] : [ReporterName, Partial<ReportOptions[ReporterName]>] : never;
981
- type Provider = 'c8' | 'istanbul' | 'custom' | undefined;
987
+ type Provider = 'c8' | 'v8' | 'istanbul' | 'custom' | undefined;
982
988
  type CoverageOptions<T extends Provider = Provider> = T extends 'istanbul' ? ({
983
989
  provider: T;
984
990
  } & CoverageIstanbulOptions) : T extends 'c8' ? ({
985
991
  provider: T;
986
- } & CoverageC8Options) : T extends 'custom' ? ({
992
+ } & CoverageC8Options) : T extends 'v8' ? ({
993
+ provider: T;
994
+ } & CoverageV8Options) : T extends 'custom' ? ({
987
995
  provider: T;
988
996
  } & CustomProviderOptions) : ({
989
997
  provider?: T;
@@ -1140,6 +1148,14 @@ interface CoverageC8Options extends BaseCoverageOptions {
1140
1148
  */
1141
1149
  100?: boolean;
1142
1150
  }
1151
+ interface CoverageV8Options extends BaseCoverageOptions {
1152
+ /**
1153
+ * Shortcut for `--check-coverage --lines 100 --functions 100 --branches 100 --statements 100`
1154
+ *
1155
+ * @default false
1156
+ */
1157
+ 100?: boolean;
1158
+ }
1143
1159
  interface CustomProviderOptions extends Pick<BaseCoverageOptions, FieldsWithDefaultValues> {
1144
1160
  /** Name of the module or path to a file to load the custom provider from */
1145
1161
  customProviderModule: string;
@@ -1229,7 +1245,7 @@ interface BenchmarkUserOptions {
1229
1245
  /**
1230
1246
  * Include globs for benchmark test files
1231
1247
  *
1232
- * @default ['**\/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
1248
+ * @default ['**\/*.{bench,benchmark}.?(c|m)[jt]s?(x)']
1233
1249
  */
1234
1250
  include?: string[];
1235
1251
  /**
@@ -1323,12 +1339,16 @@ interface SequenceOptions {
1323
1339
  */
1324
1340
  hooks?: SequenceHooks;
1325
1341
  }
1342
+ type DepsOptimizationOptions = Omit<DepOptimizationConfig, 'disabled' | 'noDiscovery'> & {
1343
+ enabled: boolean;
1344
+ };
1326
1345
  interface DepsOptions {
1327
1346
  /**
1328
1347
  * Enable dependency optimization. This can improve the performance of your tests.
1329
1348
  */
1330
- experimentalOptimizer?: Omit<DepOptimizationConfig, 'disabled' | 'noDiscovery'> & {
1331
- enabled: boolean;
1349
+ experimentalOptimizer?: {
1350
+ web?: DepsOptimizationOptions;
1351
+ ssr?: DepsOptimizationOptions;
1332
1352
  };
1333
1353
  /**
1334
1354
  * Externalize means that Vite will bypass the package to native Node.
@@ -1387,7 +1407,7 @@ interface InlineConfig {
1387
1407
  /**
1388
1408
  * Include globs for test files
1389
1409
  *
1390
- * @default ['**\/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
1410
+ * @default ['**\/*.{test,spec}.?(c|m)[jt]s?(x)']
1391
1411
  */
1392
1412
  include?: string[];
1393
1413
  /**
@@ -1960,4 +1980,4 @@ type Context = RootAndTarget & {
1960
1980
  lastActivePath?: string;
1961
1981
  };
1962
1982
 
1963
- export { CoverageOptions as $, AfterSuiteRunMeta as A, BenchmarkAPI as B, ChaiConfig as C, Arrayable as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, ArgumentsType$1 as G, MutableArray as H, InlineConfig as I, JSDOMOptions as J, Constructable as K, ModuleCache as L, MockFactoryWithHelper as M, Nullable as N, EnvironmentReturn as O, ProjectConfig as P, Environment as Q, RuntimeConfig as R, OnServerRestartHandler as S, TscErrorInfo as T, UserConsoleLog as U, VitestEnvironment as V, WorkerContext as W, CoverageProvider as X, ReportContext as Y, CoverageProviderModule as Z, CoverageReporter as _, ResolvedConfig as a, ResolvedCoverageOptions as a0, BaseCoverageOptions as a1, CoverageIstanbulOptions as a2, CoverageC8Options as a3, CustomProviderOptions as a4, BenchmarkUserOptions as a5, Benchmark as a6, BenchmarkResult as a7, BenchFunction as a8, MockFactory as a9, MockMap as aa, TestSequencer as ab, WorkspaceSpec as ac, WorkspaceProject as ad, startVitest as ae, TestSequencerConstructor as af, HtmlOptions as ag, FileOptions as ah, CloverOptions as ai, CoberturaOptions as aj, HtmlSpaOptions as ak, LcovOptions as al, LcovOnlyOptions as am, TeamcityOptions as an, TextOptions as ao, ProjectOptions as ap, ModuleGraphData as b, Reporter as c, createExpect as d, RawErrsMap as e, CollectLineNumbers as f, globalExpect as g, CollectLines as h, RootAndTarget as i, Context as j, BuiltinEnvironment as k, VitestPool as l, CSSModuleScopeStrategy as m, ApiConfig as n, VitestRunMode as o, TypecheckConfig as p, UserConfig as q, RuntimeRPC as r, setupChaiConfig as s, RunnerRPC as t, ContextTestEnvironment as u, ContextRPC as v, Vitest as w, ResolveIdFunction as x, WorkerGlobalState as y, Awaitable as z };
1983
+ export { CoverageReporter as $, AfterSuiteRunMeta as A, BenchmarkAPI as B, ChaiConfig as C, DepsOptimizationOptions as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, Arrayable as G, ArgumentsType$1 as H, InlineConfig as I, JSDOMOptions as J, MutableArray as K, Constructable as L, MockFactoryWithHelper as M, Nullable as N, ModuleCache as O, ProjectConfig as P, EnvironmentReturn as Q, RuntimeConfig as R, Environment as S, TscErrorInfo as T, UserConsoleLog as U, VitestEnvironment as V, WorkerContext as W, OnServerRestartHandler as X, CoverageProvider as Y, ReportContext as Z, CoverageProviderModule as _, ResolvedConfig as a, CoverageOptions as a0, ResolvedCoverageOptions as a1, BaseCoverageOptions as a2, CoverageIstanbulOptions as a3, CoverageC8Options as a4, CoverageV8Options as a5, CustomProviderOptions as a6, BenchmarkUserOptions as a7, Benchmark as a8, BenchmarkResult as a9, BenchFunction as aa, PendingSuiteMock as ab, MockFactory as ac, MockMap as ad, TestSequencer as ae, WorkspaceSpec as af, WorkspaceProject as ag, startVitest as ah, TestSequencerConstructor as ai, HtmlOptions as aj, FileOptions as ak, CloverOptions as al, CoberturaOptions as am, HtmlSpaOptions as an, LcovOptions as ao, LcovOnlyOptions as ap, TeamcityOptions as aq, TextOptions as ar, ProjectOptions as as, ModuleGraphData as b, Reporter as c, createExpect as d, RawErrsMap as e, CollectLineNumbers as f, globalExpect as g, CollectLines as h, RootAndTarget as i, Context as j, BuiltinEnvironment as k, VitestPool as l, CSSModuleScopeStrategy as m, ApiConfig as n, VitestRunMode as o, TypecheckConfig as p, UserConfig as q, RuntimeRPC as r, setupChaiConfig as s, RunnerRPC as t, ContextTestEnvironment as u, ContextRPC as v, Vitest as w, ResolveIdFunction as x, WorkerGlobalState as y, Awaitable as z };