vitest 0.25.6 → 0.25.7

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,6 +1,6 @@
1
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-81973d31.js';
2
- import { b as ResolvedConfig } from './types-1cf24598.js';
3
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-1cf24598.js';
1
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-fde81ec3.js';
2
+ import { b as ResolvedConfig } from './types-c441ef31.js';
3
+ export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-c441ef31.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
@@ -35,7 +35,7 @@ import { stripLiteral } from 'strip-literal';
35
35
  import require$$0$2 from 'readline';
36
36
  import { p as prompts } from './vendor-index.9f20a9be.js';
37
37
 
38
- var version$1 = "0.25.6";
38
+ var version$1 = "0.25.7";
39
39
 
40
40
  class EndError extends Error {
41
41
  constructor(value) {
@@ -8727,7 +8727,7 @@ function escapeXML(value) {
8727
8727
  );
8728
8728
  }
8729
8729
  function executionTime(durationMS) {
8730
- return (durationMS / 1e3).toLocaleString(void 0, { useGrouping: false, maximumFractionDigits: 10 });
8730
+ return (durationMS / 1e3).toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 10 });
8731
8731
  }
8732
8732
  function getDuration(task) {
8733
8733
  var _a;
@@ -10207,7 +10207,7 @@ createLogUpdate(process$1.stdout);
10207
10207
 
10208
10208
  createLogUpdate(process$1.stderr);
10209
10209
 
10210
- var version = "0.25.6";
10210
+ var version = "0.25.7";
10211
10211
 
10212
10212
  function fileFromParsedStack(stack) {
10213
10213
  var _a, _b;
@@ -10519,6 +10519,7 @@ class Vitest {
10519
10519
  this.restartsCount = 0;
10520
10520
  this.runner = void 0;
10521
10521
  this._onRestartListeners = [];
10522
+ this._onSetServer = [];
10522
10523
  this.unregisterWatcher = noop$1;
10523
10524
  this.logger = new Logger(this);
10524
10525
  }
@@ -10571,6 +10572,7 @@ class Vitest {
10571
10572
  await this.cache.results.readFromCache();
10572
10573
  } catch {
10573
10574
  }
10575
+ await Promise.all(this._onSetServer.map((fn) => fn()));
10574
10576
  }
10575
10577
  async initCoverageProvider() {
10576
10578
  if (this.coverageProvider !== void 0)
@@ -10973,6 +10975,9 @@ class Vitest {
10973
10975
  onServerRestart(fn) {
10974
10976
  this._onRestartListeners.push(fn);
10975
10977
  }
10978
+ onAfterSetServer(fn) {
10979
+ this._onSetServer.push(fn);
10980
+ }
10976
10981
  }
10977
10982
 
10978
10983
  function generateCssFilenameHash(filepath) {
@@ -11554,8 +11559,9 @@ async function startVitest(mode, cliFilters, options, viteOverrides) {
11554
11559
  ctx.report("onServerRestart", reason);
11555
11560
  if (process.env.VITEST_CLI_WRAPPER)
11556
11561
  process.exit(EXIT_CODE_RESTART);
11557
- else
11558
- ctx.start(cliFilters);
11562
+ });
11563
+ ctx.onAfterSetServer(() => {
11564
+ ctx.start(cliFilters);
11559
11565
  });
11560
11566
  try {
11561
11567
  await ctx.start(cliFilters);
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { p as picocolors, n as normalize } from './chunk-utils-env.03f840f2.js';
2
2
  import { EventEmitter } from 'events';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.328ed604.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.5a3e0bdc.js';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-1cf24598.js';
3
+ import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-c441ef31.js';
4
4
  import 'tinybench';
5
5
  import 'fs';
6
6
  import 'worker_threads';
@@ -1,4 +1,4 @@
1
- import { ae as Environment } from './types-1cf24598.js';
1
+ import { ae as Environment } from './types-c441ef31.js';
2
2
  import 'vite';
3
3
  import 'tinybench';
4
4
  import 'fs';
@@ -1,5 +1,5 @@
1
1
  import { SpyImpl } from 'tinyspy';
2
- import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-1cf24598.js';
2
+ import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-c441ef31.js';
3
3
 
4
4
  declare type Not<T extends boolean> = T extends true ? false : true;
5
5
  declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-81973d31.js';
2
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-81973d31.js';
3
- import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-1cf24598.js';
4
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-1cf24598.js';
1
+ import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-fde81ec3.js';
2
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-fde81ec3.js';
3
+ import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-c441ef31.js';
4
+ export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-c441ef31.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as ModuleCacheMap, ay as ViteNodeRunnerOptions, az as MockMap, aA as ViteNodeRunner, aB as TestSequencer } from './types-1cf24598.js';
2
- export { aB as TestSequencer, aD as TestSequencerConstructor, N as Vitest, aC as startVitest } from './types-1cf24598.js';
1
+ import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as ModuleCacheMap, ay as ViteNodeRunnerOptions, az as MockMap, aA as ViteNodeRunner, aB as TestSequencer } from './types-c441ef31.js';
2
+ export { aB as TestSequencer, aD as TestSequencerConstructor, N as Vitest, aC as startVitest } from './types-c441ef31.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import 'tinybench';
5
5
  import 'fs';
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.328ed604.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.5a3e0bdc.js';
2
2
  export { V as VitestRunner } from './chunk-runtime-mocker.bf08ae09.js';
3
3
  import './chunk-utils-env.03f840f2.js';
4
4
  import 'tty';
@@ -211,6 +211,7 @@ interface CustomEventMap {
211
211
 
212
212
  interface InvalidatePayload {
213
213
  path: string
214
+ message: string | undefined
214
215
  }
215
216
 
216
217
  type InferCustomEventPayload<T extends string> =
@@ -228,22 +229,21 @@ interface ViteHotContext {
228
229
  accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
229
230
  accept(
230
231
  deps: readonly string[],
231
- cb: (mods: Array<ModuleNamespace | undefined>) => void
232
+ cb: (mods: Array<ModuleNamespace | undefined>) => void,
232
233
  ): void
233
234
 
234
- acceptExports(exportNames: string | readonly string[]): void
235
235
  acceptExports(
236
236
  exportNames: string | readonly string[],
237
- cb: (mod: ModuleNamespace | undefined) => void
237
+ cb?: (mod: ModuleNamespace | undefined) => void,
238
238
  ): void
239
239
 
240
240
  dispose(cb: (data: any) => void): void
241
- decline(): void
242
- invalidate(): void
241
+ prune(cb: (data: any) => void): void
242
+ invalidate(message?: string): void
243
243
 
244
244
  on<T extends string>(
245
245
  event: T,
246
- cb: (payload: InferCustomEventPayload<T>) => void
246
+ cb: (payload: InferCustomEventPayload<T>) => void,
247
247
  ): void
248
248
  send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
249
249
  }
@@ -641,6 +641,7 @@ declare class Vitest {
641
641
  runner: ViteNodeRunner;
642
642
  constructor(mode: VitestRunMode);
643
643
  private _onRestartListeners;
644
+ private _onSetServer;
644
645
  setServer(options: UserConfig, server: ViteDevServer): Promise<void>;
645
646
  initCoverageProvider(): Promise<CoverageProvider | null | undefined>;
646
647
  getSerializableConfig(): ResolvedConfig;
@@ -672,6 +673,7 @@ declare class Vitest {
672
673
  isTargetFile(id: string, source?: string): Promise<boolean>;
673
674
  isInSourceTestFile(code: string): boolean;
674
675
  onServerRestart(fn: OnServerRestartHandler): void;
676
+ onAfterSetServer(fn: OnServerRestartHandler): void;
675
677
  }
676
678
 
677
679
  declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.25.6",
4
+ "version": "0.25.7",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -113,7 +113,7 @@
113
113
  "tinybench": "^2.3.1",
114
114
  "tinypool": "^0.3.0",
115
115
  "tinyspy": "^1.0.2",
116
- "vite": "^3.0.0"
116
+ "vite": "^3.0.0 || ^4.0.0"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@antfu/install-pkg": "^0.1.1",
@@ -125,7 +125,7 @@
125
125
  "@types/natural-compare": "^1.4.1",
126
126
  "@types/prompts": "^2.4.1",
127
127
  "@types/sinonjs__fake-timers": "^8.1.2",
128
- "@vitest/ui": "0.25.6",
128
+ "@vitest/ui": "0.25.7",
129
129
  "birpc": "^0.2.3",
130
130
  "cac": "^6.7.14",
131
131
  "chai-subset": "^1.6.0",
@@ -154,7 +154,7 @@
154
154
  "rollup": "^2.79.1",
155
155
  "strip-ansi": "^7.0.1",
156
156
  "typescript": "^4.8.4",
157
- "vite-node": "0.25.6",
157
+ "vite-node": "0.25.7",
158
158
  "ws": "^8.11.0"
159
159
  },
160
160
  "scripts": {