vitest 2.1.1 → 2.1.2

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 (52) hide show
  1. package/dist/browser.d.ts +5 -5
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.BlXpj3e_.js → base.DwXGwWst.js} +1 -10
  4. package/dist/chunks/{base.CsQmmYBA.js → base.tiemDJX6.js} +1 -1
  5. package/dist/chunks/{benchmark.puBFxyfE.d.ts → benchmark.JVlTzojj.d.ts} +2 -0
  6. package/dist/chunks/{cac.BVmpoFAv.js → cac.B9PaPYY1.js} +7 -7
  7. package/dist/chunks/cli-api.CHxC4-U8.js +11754 -0
  8. package/dist/chunks/{config.CHuotKvS.d.ts → config.Crbj2GAb.d.ts} +3 -0
  9. package/dist/chunks/{creator.BteLTfY8.js → creator.Cf-MKt9i.js} +4 -7
  10. package/dist/chunks/{environment.C5eAp3K6.d.ts → environment.CzISCQ7o.d.ts} +1 -0
  11. package/dist/chunks/{globals.C03P0O1a.js → globals.HsM2o-0O.js} +3 -3
  12. package/dist/chunks/{index.Bn75ITYg.js → index.BpojBOif.js} +34 -25
  13. package/dist/chunks/{index.DkN6V87F.js → index.Ckn0Cw1h.js} +2 -1
  14. package/dist/chunks/{index.zPibhCkV.js → index.FcPVJkIQ.js} +633 -582
  15. package/dist/chunks/index.mAqbj9F9.js +140 -0
  16. package/dist/chunks/{reporters.WnPwkmgA.d.ts → reporters.DAfKSDh5.d.ts} +17 -12
  17. package/dist/chunks/{resolveConfig.-K5hHm0S.js → resolveConfig.D1DENLPF.js} +3490 -3338
  18. package/dist/chunks/{runBaseTests.9YDrdSI4.js → runBaseTests.D-Gcin7G.js} +5 -5
  19. package/dist/chunks/{setup-common.DV1PI68g.js → setup-common.DF96bIYE.js} +1 -1
  20. package/dist/chunks/{suite.CcK46U-P.d.ts → suite.BMWOKiTe.d.ts} +1 -1
  21. package/dist/chunks/{utils.Dbnmsfq1.js → utils.CY6Spixo.js} +26 -47
  22. package/dist/chunks/vi.DUs2eKik.js +3943 -0
  23. package/dist/chunks/{vite.D2yAwzwa.d.ts → vite.8fk186v-.d.ts} +1 -1
  24. package/dist/chunks/{worker.CmPmTxgH.d.ts → worker.Chrs-_NL.d.ts} +2 -2
  25. package/dist/chunks/{worker.Bws9Zuxu.d.ts → worker.Qtv8v5nL.d.ts} +1 -1
  26. package/dist/cli.js +2 -2
  27. package/dist/config.cjs +2 -1
  28. package/dist/config.d.ts +5 -5
  29. package/dist/config.js +2 -1
  30. package/dist/coverage.d.ts +4 -4
  31. package/dist/coverage.js +2 -2
  32. package/dist/environments.d.ts +2 -2
  33. package/dist/execute.d.ts +3 -3
  34. package/dist/index.d.ts +14 -14
  35. package/dist/index.js +5 -5
  36. package/dist/node.d.ts +8 -8
  37. package/dist/node.js +9 -9
  38. package/dist/reporters.d.ts +4 -4
  39. package/dist/reporters.js +4 -3
  40. package/dist/runners.d.ts +1 -1
  41. package/dist/runners.js +8 -2
  42. package/dist/suite.d.ts +2 -2
  43. package/dist/worker.js +11 -3
  44. package/dist/workers/forks.js +1 -1
  45. package/dist/workers/runVmTests.js +8 -5
  46. package/dist/workers/threads.js +1 -1
  47. package/dist/workers.d.ts +4 -4
  48. package/dist/workers.js +2 -2
  49. package/package.json +11 -12
  50. package/dist/chunks/cli-api.BKkmK21J.js +0 -11404
  51. package/dist/chunks/index.iyKRMe3s.js +0 -131
  52. package/dist/chunks/vi.D6IHiKAI.js +0 -3746
@@ -0,0 +1,140 @@
1
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
+ import { b as bench } from './benchmark.C8CRJYG4.js';
3
+ import { i as isFirstRun, a as runOnce } from './run-once.Sxe67Wng.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.DUs2eKik.js';
5
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
6
+ import * as chai from 'chai';
7
+ import { assert, should } from 'chai';
8
+
9
+ var dist = {};
10
+
11
+ var hasRequiredDist;
12
+
13
+ function requireDist () {
14
+ if (hasRequiredDist) return dist;
15
+ hasRequiredDist = 1;
16
+ (function (exports) {
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.expectTypeOf = void 0;
19
+ const fn = () => true;
20
+ /**
21
+ * Similar to Jest's `expect`, but with type-awareness.
22
+ * Gives you access to a number of type-matchers that let you make assertions about the
23
+ * form of a reference or generic type parameter.
24
+ *
25
+ * @example
26
+ * import {foo, bar} from '../foo'
27
+ * import {expectTypeOf} from 'expect-type'
28
+ *
29
+ * test('foo types', () => {
30
+ * // make sure `foo` has type {a: number}
31
+ * expectTypeOf(foo).toMatchTypeOf({a: 1})
32
+ * expectTypeOf(foo).toHaveProperty('a').toBeNumber()
33
+ *
34
+ * // make sure `bar` is a function taking a string:
35
+ * expectTypeOf(bar).parameter(0).toBeString()
36
+ * expectTypeOf(bar).returns.not.toBeAny()
37
+ * })
38
+ *
39
+ * @description
40
+ * See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.
41
+ */
42
+ const expectTypeOf = (_actual) => {
43
+ const nonFunctionProperties = [
44
+ 'parameters',
45
+ 'returns',
46
+ 'resolves',
47
+ 'not',
48
+ 'items',
49
+ 'constructorParameters',
50
+ 'thisParameter',
51
+ 'instance',
52
+ 'guards',
53
+ 'asserts',
54
+ 'branded',
55
+ ];
56
+ const obj = {
57
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
58
+ toBeAny: fn,
59
+ toBeUnknown: fn,
60
+ toBeNever: fn,
61
+ toBeFunction: fn,
62
+ toBeObject: fn,
63
+ toBeArray: fn,
64
+ toBeString: fn,
65
+ toBeNumber: fn,
66
+ toBeBoolean: fn,
67
+ toBeVoid: fn,
68
+ toBeSymbol: fn,
69
+ toBeNull: fn,
70
+ toBeUndefined: fn,
71
+ toBeNullable: fn,
72
+ toMatchTypeOf: fn,
73
+ toEqualTypeOf: fn,
74
+ toBeCallableWith: fn,
75
+ toBeConstructibleWith: fn,
76
+ /* eslint-enable @typescript-eslint/no-unsafe-assignment */
77
+ extract: exports.expectTypeOf,
78
+ exclude: exports.expectTypeOf,
79
+ pick: exports.expectTypeOf,
80
+ omit: exports.expectTypeOf,
81
+ toHaveProperty: exports.expectTypeOf,
82
+ parameter: exports.expectTypeOf,
83
+ };
84
+ const getterProperties = nonFunctionProperties;
85
+ getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
86
+ return obj;
87
+ };
88
+ exports.expectTypeOf = expectTypeOf;
89
+ } (dist));
90
+ return dist;
91
+ }
92
+
93
+ var distExports = requireDist();
94
+
95
+ function noop() {
96
+ }
97
+ const assertType = noop;
98
+
99
+ function getRunningMode() {
100
+ return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
101
+ }
102
+ function isWatchMode() {
103
+ return getRunningMode() === "watch";
104
+ }
105
+
106
+ function inject(key) {
107
+ const workerState = getWorkerState();
108
+ return workerState.providedContext[key];
109
+ }
110
+
111
+ var VitestIndex = /*#__PURE__*/Object.freeze({
112
+ __proto__: null,
113
+ afterAll: afterAll,
114
+ afterEach: afterEach,
115
+ assert: assert,
116
+ assertType: assertType,
117
+ beforeAll: beforeAll,
118
+ beforeEach: beforeEach,
119
+ bench: bench,
120
+ chai: chai,
121
+ createExpect: createExpect,
122
+ describe: describe,
123
+ expect: globalExpect,
124
+ expectTypeOf: distExports.expectTypeOf,
125
+ getRunningMode: getRunningMode,
126
+ inject: inject,
127
+ isFirstRun: isFirstRun,
128
+ isWatchMode: isWatchMode,
129
+ it: it,
130
+ onTestFailed: onTestFailed,
131
+ onTestFinished: onTestFinished,
132
+ runOnce: runOnce,
133
+ should: should,
134
+ suite: suite,
135
+ test: test,
136
+ vi: vi,
137
+ vitest: vitest
138
+ });
139
+
140
+ export { VitestIndex as V, assertType as a, inject as b, distExports as d, getRunningMode as g, isWatchMode as i };
@@ -3,10 +3,10 @@ import { File, Test, Suite, TaskResultPack, Task, CancelReason, Custom, TaskMeta
3
3
  import * as vite from 'vite';
4
4
  import { ViteDevServer, TransformResult as TransformResult$1, ServerOptions, DepOptimizationConfig, AliasOptions, UserConfig as UserConfig$1, ConfigEnv } from 'vite';
5
5
  import { PrettyFormatOptions } from '@vitest/pretty-format';
6
- import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.CHuotKvS.js';
6
+ import { S as SerializedConfig, F as FakeTimerInstallOpts } from './config.Crbj2GAb.js';
7
7
  import { RawSourceMap, ViteNodeServerOptions } from 'vite-node';
8
8
  import { SnapshotSummary, SnapshotStateOptions } from '@vitest/snapshot';
9
- import { b as Awaitable, P as ProvidedContext, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable, d as ArgumentsType, O as OnServerRestartHandler, f as EnvironmentOptions } from './environment.C5eAp3K6.js';
9
+ import { b as Awaitable, P as ProvidedContext, U as UserConsoleLog, A as AfterSuiteRunMeta, c as Arrayable, d as ArgumentsType, O as OnServerRestartHandler, f as EnvironmentOptions } from './environment.CzISCQ7o.js';
10
10
  import { Writable } from 'node:stream';
11
11
  import { ViteNodeRunner } from 'vite-node/client';
12
12
  import { SnapshotManager } from '@vitest/snapshot/manager';
@@ -15,7 +15,7 @@ import { ParsedStack, Awaitable as Awaitable$1, ErrorWithDiff, TestError, Arraya
15
15
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
16
16
  import { Stats } from 'node:fs';
17
17
  import * as chai from 'chai';
18
- import { B as BenchmarkResult } from './benchmark.puBFxyfE.js';
18
+ import { B as BenchmarkResult } from './benchmark.JVlTzojj.js';
19
19
 
20
20
  type BuiltinPool = 'browser' | 'threads' | 'forks' | 'vmThreads' | 'vmForks' | 'typescript';
21
21
  type Pool = BuiltinPool | (string & {});
@@ -774,7 +774,7 @@ declare class ReportedTaskImplementation {
774
774
  /**
775
775
  * Creates a new reported task instance and stores it in the project's state for future use.
776
776
  */
777
- static register(task: Task, project: WorkspaceProject): TestCase | TestSuite | TestModule;
777
+ static register(task: Task, project: WorkspaceProject): TestModule | TestCase | TestSuite;
778
778
  }
779
779
  declare class TestCase extends ReportedTaskImplementation {
780
780
  #private;
@@ -1006,7 +1006,7 @@ declare class StateManager {
1006
1006
  taskFileMap: WeakMap<Task, File>;
1007
1007
  errorsSet: Set<unknown>;
1008
1008
  processTimeoutCauses: Set<string>;
1009
- reportedTasksMap: WeakMap<Task, TestCase | TestSuite | TestModule>;
1009
+ reportedTasksMap: WeakMap<Task, TestModule | TestCase | TestSuite>;
1010
1010
  catchError(err: unknown, type: string): void;
1011
1011
  clearErrors(): void;
1012
1012
  getUnhandledErrors(): unknown[];
@@ -1023,7 +1023,7 @@ declare class StateManager {
1023
1023
  collectFiles(project: WorkspaceProject, files?: File[]): void;
1024
1024
  clearFiles(project: WorkspaceProject, paths?: string[]): void;
1025
1025
  updateId(task: Task, project: WorkspaceProject): void;
1026
- getReportedEntity(task: Task): TestCase | TestSuite | TestModule | undefined;
1026
+ getReportedEntity(task: Task): TestModule | TestCase | TestSuite | undefined;
1027
1027
  updateTasks(packs: TaskResultPack[]): void;
1028
1028
  updateUserLog(log: UserConsoleLog): void;
1029
1029
  getCountOfFailedTests(): number;
@@ -1071,7 +1071,7 @@ declare class VitestCache {
1071
1071
  }
1072
1072
 
1073
1073
  declare class VitestPackageInstaller {
1074
- ensureInstalled(dependency: string, root: string): Promise<boolean>;
1074
+ ensureInstalled(dependency: string, root: string, version?: string): Promise<boolean>;
1075
1075
  }
1076
1076
 
1077
1077
  interface Node {
@@ -1161,6 +1161,8 @@ interface CoverageProvider {
1161
1161
  clean: (clean?: boolean) => void | Promise<void>;
1162
1162
  /** Called with coverage results after a single test file has been run */
1163
1163
  onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void | Promise<void>;
1164
+ /** Callback called when test run fails */
1165
+ onTestFailure?: () => void | Promise<void>;
1164
1166
  /** Callback to generate final coverage results */
1165
1167
  generateCoverage: (reportContext: ReportContext) => CoverageResults | Promise<CoverageResults>;
1166
1168
  /** Callback to convert coverage results to coverage reports. Called with results returned from `generateCoverage` */
@@ -1777,10 +1779,8 @@ declare class TableReporter extends BaseReporter {
1777
1779
  interface FlatBenchmarkReport {
1778
1780
  [id: string]: FormattedBenchmarkResult;
1779
1781
  }
1780
- type FormattedBenchmarkResult = Omit<BenchmarkResult, 'samples'> & {
1782
+ type FormattedBenchmarkResult = BenchmarkResult & {
1781
1783
  id: string;
1782
- sampleCount: number;
1783
- median: number;
1784
1784
  };
1785
1785
 
1786
1786
  declare const BenchmarkReportsMap: {
@@ -1867,8 +1867,7 @@ interface BenchmarkUserOptions {
1867
1867
  */
1868
1868
  reporters?: Arrayable$1<BenchmarkBuiltinReporters | Reporter>;
1869
1869
  /**
1870
- * Write test results to a file when the `--reporter=json` option is also specified.
1871
- * Also definable individually per reporter by using an object instead.
1870
+ * @deprecated Use `benchmark.outputJson` instead
1872
1871
  */
1873
1872
  outputFile?: string | (Partial<Record<BenchmarkBuiltinReporters, string>> & Record<string, string>);
1874
1873
  /**
@@ -1879,6 +1878,12 @@ interface BenchmarkUserOptions {
1879
1878
  * benchmark output file
1880
1879
  */
1881
1880
  outputJson?: string;
1881
+ /**
1882
+ * Include `samples` array of benchmark results for API or custom reporter usages.
1883
+ * This is disabled by default to reduce memory usage.
1884
+ * @default false
1885
+ */
1886
+ includeSamples?: boolean;
1882
1887
  }
1883
1888
 
1884
1889
  type BuiltinEnvironment = 'node' | 'jsdom' | 'happy-dom' | 'edge-runtime';