vitest 0.31.3 → 0.31.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { startTests } from '@vitest/runner';
2
- import { a as ResolvedConfig, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule } from './types-fe79687a.js';
2
+ import { a as ResolvedConfig, $ as CoverageOptions, X as CoverageProvider, Z as CoverageProviderModule } from './types-dea83b3d.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';
@@ -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.0726b980.js';
6
+ import { o as onetime$1 } from './vendor-cli-api.8cf937e8.js';
7
7
  import require$$0$2 from 'os';
8
8
  import 'node:buffer';
9
9
  import 'node:path';
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, d as divider } from './vendor-cli-api.0726b980.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.8cf937e8.js';
5
5
  import './vendor-constants.538d9b49.js';
6
6
  import './vendor-coverage.c8fd34c3.js';
7
7
  import './vendor-index.75f2b63d.js';
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-fe79687a.js';
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';
4
4
  import '@vitest/snapshot';
5
5
  import '@vitest/expect';
6
6
  import '@vitest/runner';
@@ -1,4 +1,4 @@
1
- import { a1 as BaseCoverageOptions, a0 as ResolvedCoverageOptions } from './types-fe79687a.js';
1
+ import { a1 as BaseCoverageOptions, a0 as ResolvedCoverageOptions } from './types-dea83b3d.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
@@ -1,4 +1,4 @@
1
- import { Q as Environment } from './types-fe79687a.js';
1
+ import { Q as Environment } from './types-dea83b3d.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-fe79687a.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-fe79687a.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-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';
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';
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-fe79687a.js';
2
- export { af as TestSequencerConstructor, ad as VitestWorkspace, ae as startVitest } from './types-fe79687a.js';
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';
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';
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.0726b980.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './vendor-cli-api.8cf937e8.js';
2
2
  export { V as VitestExecutor } from './vendor-execute.132a3e09.js';
3
3
  import 'pathe';
4
4
  import './vendor-constants.538d9b49.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-fe79687a.js';
2
+ import { a as ResolvedConfig } from './types-dea83b3d.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';
@@ -1327,7 +1327,7 @@ interface DepsOptions {
1327
1327
  /**
1328
1328
  * Enable dependency optimization. This can improve the performance of your tests.
1329
1329
  */
1330
- experimentalOptimizer?: Omit<DepOptimizationConfig, 'disabled'> & {
1330
+ experimentalOptimizer?: Omit<DepOptimizationConfig, 'disabled' | 'noDiscovery'> & {
1331
1331
  enabled: boolean;
1332
1332
  };
1333
1333
  /**
@@ -7,7 +7,7 @@ import c from 'picocolors';
7
7
  import { isPackageExists, resolveModule } from 'local-pkg';
8
8
  import { i as isNode, r as relativePath, a as removeUndefinedValues, b as isWindows } from './vendor-index.fad2598b.js';
9
9
  import { isCI } from 'std-env';
10
- import { loadConfigFromFile, createServer, mergeConfig } from 'vite';
10
+ import { loadConfigFromFile, createServer, version as version$2, mergeConfig } from 'vite';
11
11
  import path$a from 'node:path';
12
12
  import process$1 from 'node:process';
13
13
  import fs$8, { promises, existsSync, readFileSync } from 'node:fs';
@@ -33,7 +33,7 @@ import { createDefer, getSafeTimers, notNullish, parseErrorStacktrace, shuffle,
33
33
  import { performance } from 'node:perf_hooks';
34
34
  import { g as getFullName, h as hasFailedSnapshot } from './vendor-tasks.f9d75aed.js';
35
35
  import { getTests, hasFailed, getSuites, generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks } from '@vitest/runner/utils';
36
- import { createRequire } from 'node:module';
36
+ import { createRequire, builtinModules } from 'node:module';
37
37
  import { createHash } from 'node:crypto';
38
38
  import { s as signalExit, e as execa } from './vendor-index.c1e09929.js';
39
39
  import { writeFile, rm } from 'node:fs/promises';
@@ -60,7 +60,7 @@ function _mergeNamespaces(n, m) {
60
60
  return Object.freeze(n);
61
61
  }
62
62
 
63
- var version$1 = "0.31.3";
63
+ var version$1 = "0.31.4";
64
64
 
65
65
  const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
66
66
  async function ensurePackageInstalled(dependency, root) {
@@ -79,7 +79,7 @@ async function ensurePackageInstalled(dependency, root) {
79
79
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
80
80
  });
81
81
  if (install) {
82
- await (await import('./chunk-install-pkg.1ed93fe7.js')).installPackage(dependency, { dev: true });
82
+ await (await import('./chunk-install-pkg.4f68b0aa.js')).installPackage(dependency, { dev: true });
83
83
  process.stderr.write(c.yellow(`
84
84
  Package ${dependency} installed, re-run the command to start.
85
85
  `));
@@ -11165,7 +11165,7 @@ createLogUpdate(process$1.stdout);
11165
11165
 
11166
11166
  createLogUpdate(process$1.stderr);
11167
11167
 
11168
- var version = "0.31.3";
11168
+ var version = "0.31.4";
11169
11169
 
11170
11170
  const comma = ','.charCodeAt(0);
11171
11171
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -12375,9 +12375,12 @@ As a temporary workaround you can try to inline the package by updating your con
12375
12375
  ` + c.gray(c.dim("// vitest.config.js")) + "\n" + c.green(`export default {
12376
12376
  test: {
12377
12377
  deps: {
12378
- inline: [
12379
- ${c.yellow(c.bold(`"${name}"`))}
12380
- ]
12378
+ experimentalOptimizer: {
12379
+ enabled: true,
12380
+ include: [
12381
+ ${c.yellow(c.bold(`"${name}"`))}
12382
+ ]
12383
+ }
12381
12384
  }
12382
12385
  }
12383
12386
  }
@@ -13067,7 +13070,7 @@ function WorkspaceVitestPlugin(project, options) {
13067
13070
  },
13068
13071
  // TODO: refactor so we don't have the same code here and in plugins/index.ts
13069
13072
  config(viteConfig) {
13070
- var _a, _b, _c;
13073
+ var _a, _b, _c, _d, _e, _f, _g;
13071
13074
  if (viteConfig.define) {
13072
13075
  delete viteConfig.define["import.meta.vitest"];
13073
13076
  delete viteConfig.define["process.env"];
@@ -13145,6 +13148,33 @@ function WorkspaceVitestPlugin(project, options) {
13145
13148
  };
13146
13149
  }
13147
13150
  }
13151
+ const optimizeConfig = {};
13152
+ const optimizer = (_d = testConfig.deps) == null ? void 0 : _d.experimentalOptimizer;
13153
+ const [major, minor] = version$2.split(".").map(Number);
13154
+ const allowed = major >= 5 || major === 4 && minor >= 3;
13155
+ if (!allowed && (optimizer == null ? void 0 : optimizer.enabled) === true)
13156
+ console.warn(`Vitest: "deps.experimentalOptimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
13157
+ if (!allowed || (optimizer == null ? void 0 : optimizer.enabled) !== true) {
13158
+ optimizeConfig.cacheDir = void 0;
13159
+ optimizeConfig.optimizeDeps = {
13160
+ // experimental in Vite >2.9.2, entries remains to help with older versions
13161
+ disabled: true,
13162
+ entries: []
13163
+ };
13164
+ } else {
13165
+ const cacheDir = testConfig.cache !== false ? (_e = testConfig.cache) == null ? void 0 : _e.dir : null;
13166
+ optimizeConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
13167
+ optimizeConfig.optimizeDeps = {
13168
+ ...viteConfig.optimizeDeps,
13169
+ ...optimizer,
13170
+ noDiscovery: true,
13171
+ disabled: false,
13172
+ entries: [],
13173
+ exclude: ["vitest", ...builtinModules, ...optimizer.exclude || ((_f = viteConfig.optimizeDeps) == null ? void 0 : _f.exclude) || []],
13174
+ include: (optimizer.include || ((_g = viteConfig.optimizeDeps) == null ? void 0 : _g.include) || []).filter((n) => n !== "vitest")
13175
+ };
13176
+ }
13177
+ Object.assign(config, optimizeConfig);
13148
13178
  return config;
13149
13179
  },
13150
13180
  async configureServer(server) {
@@ -14021,7 +14051,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14021
14051
  this.meta.watchMode = false;
14022
14052
  },
14023
14053
  async config(viteConfig) {
14024
- var _a, _b, _c, _d;
14054
+ var _a, _b, _c, _d, _e, _f, _g, _h;
14025
14055
  if (options.watch) {
14026
14056
  options = deepMerge({}, userConfig);
14027
14057
  }
@@ -14101,12 +14131,31 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
14101
14131
  }
14102
14132
  }
14103
14133
  const optimizeConfig = {};
14104
- optimizeConfig.cacheDir = void 0;
14105
- optimizeConfig.optimizeDeps = {
14106
- // experimental in Vite >2.9.2, entries remains to help with older versions
14107
- disabled: true,
14108
- entries: []
14109
- };
14134
+ const optimizer = (_e = preOptions.deps) == null ? void 0 : _e.experimentalOptimizer;
14135
+ const [major, minor] = version$2.split(".").map(Number);
14136
+ const allowed = major >= 5 || major === 4 && minor >= 3;
14137
+ if (!allowed && (optimizer == null ? void 0 : optimizer.enabled) === true)
14138
+ console.warn(`Vitest: "deps.experimentalOptimizer" is only available in Vite >= 4.3.0, current Vite version: ${version$2}`);
14139
+ if (!allowed || (optimizer == null ? void 0 : optimizer.enabled) !== true) {
14140
+ optimizeConfig.cacheDir = void 0;
14141
+ optimizeConfig.optimizeDeps = {
14142
+ // experimental in Vite >2.9.2, entries remains to help with older versions
14143
+ disabled: true,
14144
+ entries: []
14145
+ };
14146
+ } else {
14147
+ const cacheDir = preOptions.cache !== false ? (_f = preOptions.cache) == null ? void 0 : _f.dir : null;
14148
+ optimizeConfig.cacheDir = cacheDir ?? "node_modules/.vitest";
14149
+ optimizeConfig.optimizeDeps = {
14150
+ ...viteConfig.optimizeDeps,
14151
+ ...optimizer,
14152
+ noDiscovery: true,
14153
+ disabled: false,
14154
+ entries: [],
14155
+ exclude: ["vitest", ...builtinModules, ...optimizer.exclude || ((_g = viteConfig.optimizeDeps) == null ? void 0 : _g.exclude) || []],
14156
+ include: (optimizer.include || ((_h = viteConfig.optimizeDeps) == null ? void 0 : _h.include) || []).filter((n) => n !== "vitest")
14157
+ };
14158
+ }
14110
14159
  Object.assign(config, optimizeConfig);
14111
14160
  return config;
14112
14161
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.31.3",
4
+ "version": "0.31.4",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -148,12 +148,12 @@
148
148
  "tinypool": "^0.5.0",
149
149
  "vite": "^3.0.0 || ^4.0.0",
150
150
  "why-is-node-running": "^2.2.2",
151
- "@vitest/runner": "0.31.3",
152
- "@vitest/spy": "0.31.3",
153
- "@vitest/snapshot": "0.31.3",
154
- "vite-node": "0.31.3",
155
- "@vitest/expect": "0.31.3",
156
- "@vitest/utils": "0.31.3"
151
+ "@vitest/runner": "0.31.4",
152
+ "@vitest/expect": "0.31.4",
153
+ "@vitest/snapshot": "0.31.4",
154
+ "@vitest/spy": "0.31.4",
155
+ "vite-node": "0.31.4",
156
+ "@vitest/utils": "0.31.4"
157
157
  },
158
158
  "devDependencies": {
159
159
  "@ampproject/remapping": "^2.2.1",