vitest 2.1.3 → 2.1.5

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 (75) hide show
  1. package/LICENSE.md +1 -209
  2. package/dist/browser.d.ts +24 -24
  3. package/dist/browser.js +7 -7
  4. package/dist/chunks/{RandomSequencer.Bh5-tlNJ.js → RandomSequencer.CMRlh2v4.js} +143 -142
  5. package/dist/chunks/{base.BO5Jx7vw.js → base.BZZh4cSm.js} +3 -3
  6. package/dist/chunks/{benchmark.C8CRJYG4.js → benchmark.Cdu9hjj4.js} +2 -2
  7. package/dist/chunks/{benchmark.JVlTzojj.d.ts → benchmark.geERunq4.d.ts} +1 -1
  8. package/dist/chunks/{cac.BSMVokHR.js → cac.DWAW3Uh5.js} +11 -10
  9. package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.BtqJwSCh.js} +828 -644
  10. package/dist/chunks/{config.Crbj2GAb.d.ts → config.Cy0C388Z.d.ts} +0 -1
  11. package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
  12. package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
  13. package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
  14. package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
  15. package/dist/chunks/{globals.Bdzt04Qm.js → globals.D8ZVAdXd.js} +8 -13
  16. package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
  17. package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
  18. package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
  19. package/dist/chunks/{index.Dz2opmmU.js → index.DsZFoqi9.js} +3711 -3788
  20. package/dist/chunks/{index.lVXYBqEP.js → index.K90BXFOx.js} +186 -186
  21. package/dist/chunks/index.ckWaX2gY.js +54 -0
  22. package/dist/chunks/{index.4GFF2h22.js → index.nEwtF0bu.js} +6 -6
  23. package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
  24. package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.D7Jzd9GS.d.ts} +1246 -1221
  25. package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.RxKrDli4.js} +3196 -3176
  26. package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
  27. package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
  28. package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.3qpJUEJM.js} +21 -25
  29. package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.Dj6BZI3u.js} +3 -3
  30. package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
  31. package/dist/chunks/utils.C8RiOc4B.js +77 -0
  32. package/dist/chunks/{utils.CY6Spixo.js → utils.DNoFbBUZ.js} +7 -3
  33. package/dist/chunks/{vi.BskyZC5g.js → vi.DgezovHB.js} +177 -142
  34. package/dist/chunks/{vite.YH7MrecS.d.ts → vite.C-N5BBZe.d.ts} +1 -1
  35. package/dist/chunks/{vm.DB_hLchi.js → vm.Zr4qWzDJ.js} +8 -8
  36. package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.B9FxPCaC.d.ts} +1 -1
  37. package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.tN5KGIih.d.ts} +14 -4
  38. package/dist/cli.js +3 -4
  39. package/dist/config.cjs +4 -4
  40. package/dist/config.d.ts +11 -11
  41. package/dist/config.js +4 -4
  42. package/dist/coverage.d.ts +10 -10
  43. package/dist/coverage.js +8 -11
  44. package/dist/environments.d.ts +2 -2
  45. package/dist/environments.js +1 -1
  46. package/dist/execute.d.ts +54 -54
  47. package/dist/execute.js +7 -6
  48. package/dist/index.d.ts +106 -1101
  49. package/dist/index.js +7 -18
  50. package/dist/node.d.ts +44 -42
  51. package/dist/node.js +23 -29
  52. package/dist/path.js +1 -1
  53. package/dist/reporters.d.ts +10 -10
  54. package/dist/reporters.js +12 -18
  55. package/dist/runners.d.ts +12 -19
  56. package/dist/runners.js +142 -148
  57. package/dist/snapshot.js +2 -6
  58. package/dist/suite.d.ts +2 -2
  59. package/dist/suite.js +2 -6
  60. package/dist/worker.js +10 -7
  61. package/dist/workers/forks.js +9 -8
  62. package/dist/workers/runVmTests.js +16 -20
  63. package/dist/workers/threads.js +9 -8
  64. package/dist/workers/vmForks.js +9 -12
  65. package/dist/workers/vmThreads.js +9 -12
  66. package/dist/workers.d.ts +14 -14
  67. package/dist/workers.js +15 -18
  68. package/package.json +27 -27
  69. package/dist/chunks/base.DwXGwWst.js +0 -89
  70. package/dist/chunks/env.CmHVDJnw.js +0 -7
  71. package/dist/chunks/index.-d_XpZEA.js +0 -140
  72. package/dist/chunks/index.CxRxs566.js +0 -23
  73. package/dist/chunks/tasks.BZnCS9aT.js +0 -18
  74. package/dist/chunks/utils.Ck2hJTRs.js +0 -23
  75. package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "2.1.3",
4
+ "version": "2.1.5",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -122,8 +122,8 @@
122
122
  "@types/node": "^18.0.0 || >=20.0.0",
123
123
  "happy-dom": "*",
124
124
  "jsdom": "*",
125
- "@vitest/ui": "2.1.3",
126
- "@vitest/browser": "2.1.3"
125
+ "@vitest/browser": "2.1.5",
126
+ "@vitest/ui": "2.1.5"
127
127
  },
128
128
  "peerDependenciesMeta": {
129
129
  "@edge-runtime/vm": {
@@ -146,55 +146,55 @@
146
146
  }
147
147
  },
148
148
  "dependencies": {
149
- "chai": "^5.1.1",
150
- "debug": "^4.3.6",
151
- "magic-string": "^0.30.11",
149
+ "chai": "^5.1.2",
150
+ "debug": "^4.3.7",
151
+ "expect-type": "^1.1.0",
152
+ "magic-string": "^0.30.12",
152
153
  "pathe": "^1.1.2",
153
- "std-env": "^3.7.0",
154
+ "std-env": "^3.8.0",
154
155
  "tinybench": "^2.9.0",
155
- "tinyexec": "^0.3.0",
156
- "tinypool": "^1.0.0",
156
+ "tinyexec": "^0.3.1",
157
+ "tinypool": "^1.0.1",
157
158
  "tinyrainbow": "^1.2.0",
158
159
  "vite": "^5.0.0",
159
160
  "why-is-node-running": "^2.3.0",
160
- "@vitest/expect": "2.1.3",
161
- "@vitest/pretty-format": "^2.1.3",
162
- "@vitest/runner": "2.1.3",
163
- "@vitest/mocker": "2.1.3",
164
- "@vitest/snapshot": "2.1.3",
165
- "@vitest/utils": "2.1.3",
166
- "vite-node": "2.1.3",
167
- "@vitest/spy": "2.1.3"
161
+ "@vitest/expect": "2.1.5",
162
+ "@vitest/mocker": "2.1.5",
163
+ "@vitest/pretty-format": "^2.1.5",
164
+ "@vitest/snapshot": "2.1.5",
165
+ "@vitest/runner": "2.1.5",
166
+ "vite-node": "2.1.5",
167
+ "@vitest/spy": "2.1.5",
168
+ "@vitest/utils": "2.1.5"
168
169
  },
169
170
  "devDependencies": {
170
171
  "@ampproject/remapping": "^2.3.0",
171
172
  "@antfu/install-pkg": "^0.4.1",
172
- "@edge-runtime/vm": "^4.0.1",
173
+ "@edge-runtime/vm": "^4.0.4",
173
174
  "@sinonjs/fake-timers": "11.1.0",
174
175
  "@types/debug": "^4.1.12",
175
- "@types/estree": "^1.0.5",
176
+ "@types/estree": "^1.0.6",
176
177
  "@types/istanbul-lib-coverage": "^2.0.6",
177
178
  "@types/istanbul-reports": "^3.0.4",
178
179
  "@types/jsdom": "^21.1.7",
179
180
  "@types/micromatch": "^4.0.9",
180
- "@types/node": "^22.5.2",
181
+ "@types/node": "^22.9.0",
181
182
  "@types/prompts": "^2.4.9",
182
183
  "@types/sinonjs__fake-timers": "^8.1.5",
183
- "acorn-walk": "^8.3.3",
184
- "birpc": "0.2.17",
184
+ "acorn-walk": "^8.3.4",
185
+ "birpc": "0.2.19",
185
186
  "cac": "^6.7.14",
186
187
  "chai-subset": "^1.6.0",
187
188
  "cli-truncate": "^4.0.0",
188
- "expect-type": "^0.19.0",
189
189
  "fast-glob": "3.3.2",
190
190
  "find-up": "^6.3.0",
191
191
  "flatted": "^3.3.1",
192
- "get-tsconfig": "^4.7.6",
193
- "happy-dom": "^15.7.3",
194
- "jsdom": "^25.0.0",
192
+ "get-tsconfig": "^4.8.1",
193
+ "happy-dom": "^15.11.4",
194
+ "jsdom": "^25.0.1",
195
195
  "local-pkg": "^0.5.0",
196
196
  "log-update": "^5.0.1",
197
- "micromatch": "^4.0.7",
197
+ "micromatch": "^4.0.8",
198
198
  "pretty-format": "^29.7.0",
199
199
  "prompts": "^2.4.2",
200
200
  "strip-literal": "^2.1.0",
@@ -1,89 +0,0 @@
1
- import '@vitest/utils';
2
-
3
- function groupBy(collection, iteratee) {
4
- return collection.reduce((acc, item) => {
5
- const key = iteratee(item);
6
- acc[key] ||= [];
7
- acc[key].push(item);
8
- return acc;
9
- }, {});
10
- }
11
- function isPrimitive(value) {
12
- return value === null || typeof value !== "function" && typeof value !== "object";
13
- }
14
- function slash(str) {
15
- return str.replace(/\\/g, "/");
16
- }
17
- function noop() {
18
- }
19
- function toArray(array) {
20
- if (array === null || array === void 0) {
21
- array = [];
22
- }
23
- if (Array.isArray(array)) {
24
- return array;
25
- }
26
- return [array];
27
- }
28
- function toString(v) {
29
- return Object.prototype.toString.call(v);
30
- }
31
- function isPlainObject(val) {
32
- return toString(val) === "[object Object]" && (!val.constructor || val.constructor.name === "Object");
33
- }
34
- function deepMerge(target, ...sources) {
35
- if (!sources.length) {
36
- return target;
37
- }
38
- const source = sources.shift();
39
- if (source === void 0) {
40
- return target;
41
- }
42
- if (isMergeableObject(target) && isMergeableObject(source)) {
43
- Object.keys(source).forEach((key) => {
44
- const _source = source;
45
- if (isMergeableObject(_source[key])) {
46
- if (!target[key]) {
47
- target[key] = {};
48
- }
49
- deepMerge(target[key], _source[key]);
50
- } else {
51
- target[key] = _source[key];
52
- }
53
- });
54
- }
55
- return deepMerge(target, ...sources);
56
- }
57
- function isMergeableObject(item) {
58
- return isPlainObject(item) && !Array.isArray(item);
59
- }
60
- function stdout() {
61
- return console._stdout || process.stdout;
62
- }
63
- class AggregateErrorPonyfill extends Error {
64
- errors;
65
- constructor(errors, message = "") {
66
- super(message);
67
- this.errors = [...errors];
68
- }
69
- }
70
- function isChildProcess() {
71
- return typeof process !== "undefined" && !!process.send;
72
- }
73
- function setProcessTitle(title) {
74
- try {
75
- process.title = `node (${title})`;
76
- } catch {
77
- }
78
- }
79
- function escapeRegExp(s) {
80
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
81
- }
82
- function wildcardPatternToRegExp(pattern) {
83
- return new RegExp(
84
- `^${pattern.split("*").map(escapeRegExp).join(".*")}$`,
85
- "i"
86
- );
87
- }
88
-
89
- export { AggregateErrorPonyfill as A, slash as a, isPrimitive as b, stdout as c, deepMerge as d, groupBy as g, isChildProcess as i, noop as n, setProcessTitle as s, toArray as t, wildcardPatternToRegExp as w };
@@ -1,7 +0,0 @@
1
- import 'std-env';
2
-
3
- const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
4
- const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
5
- const isWindows = (isNode || isDeno) && process.platform === "win32";
6
-
7
- export { isNode as a, isDeno as b, isWindows as i };
@@ -1,140 +0,0 @@
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.BskyZC5g.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 };
@@ -1,23 +0,0 @@
1
- import { relative } from 'pathe';
2
- import '@vitest/runner/utils';
3
- import '@vitest/utils';
4
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
- import './env.CmHVDJnw.js';
6
-
7
- function getRunMode() {
8
- return getWorkerState().config.mode;
9
- }
10
- function isRunningInBenchmark() {
11
- return getRunMode() === "benchmark";
12
- }
13
- const relativePath = relative;
14
- function removeUndefinedValues(obj) {
15
- for (const key in Object.keys(obj)) {
16
- if (obj[key] === void 0) {
17
- delete obj[key];
18
- }
19
- }
20
- return obj;
21
- }
22
-
23
- export { removeUndefinedValues as a, isRunningInBenchmark as i, relativePath as r };
@@ -1,18 +0,0 @@
1
- import { getNames, getTests } from '@vitest/runner/utils';
2
- import '@vitest/utils';
3
-
4
- function hasFailedSnapshot(suite) {
5
- return getTests(suite).some((s) => {
6
- return s.result?.errors?.some(
7
- (e) => typeof e?.message === "string" && e.message.match(/Snapshot .* mismatched/)
8
- );
9
- });
10
- }
11
- function getFullName(task, separator = " > ") {
12
- return getNames(task).join(separator);
13
- }
14
- function getTestName(task, separator = " > ") {
15
- return getNames(task).slice(1).join(separator);
16
- }
17
-
18
- export { getFullName as a, getTestName as g, hasFailedSnapshot as h };
@@ -1,23 +0,0 @@
1
- function getWorkerState() {
2
- const workerState = globalThis.__vitest_worker__;
3
- if (!workerState) {
4
- const errorMsg = 'Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
5
- throw new Error(errorMsg);
6
- }
7
- return workerState;
8
- }
9
- function provideWorkerState(context, state) {
10
- Object.defineProperty(context, "__vitest_worker__", {
11
- value: state,
12
- configurable: true,
13
- writable: true,
14
- enumerable: false
15
- });
16
- return state;
17
- }
18
- function getCurrentEnvironment() {
19
- const state = getWorkerState();
20
- return state?.environment.name;
21
- }
22
-
23
- export { getCurrentEnvironment as a, getWorkerState as g, provideWorkerState as p };
@@ -39,6 +39,30 @@ type OnServerRestartHandler = (reason?: string) => Promise<void> | void;
39
39
  interface ProvidedContext {
40
40
  }
41
41
 
42
+ /**
43
+ * Happy DOM options.
44
+ */
45
+ interface HappyDOMOptions {
46
+ width?: number;
47
+ height?: number;
48
+ url?: string;
49
+ settings?: {
50
+ disableJavaScriptEvaluation?: boolean;
51
+ disableJavaScriptFileLoading?: boolean;
52
+ disableCSSFileLoading?: boolean;
53
+ disableIframePageLoading?: boolean;
54
+ disableComputedStyleRendering?: boolean;
55
+ enableFileSystemHttpRequests?: boolean;
56
+ navigator?: {
57
+ userAgent?: string;
58
+ };
59
+ device?: {
60
+ prefersColorScheme?: string;
61
+ mediaType?: string;
62
+ };
63
+ };
64
+ }
65
+
42
66
  interface JSDOMOptions {
43
67
  /**
44
68
  * The html content for the test.
@@ -119,30 +143,6 @@ interface JSDOMOptions {
119
143
  resources?: 'usable';
120
144
  }
121
145
 
122
- /**
123
- * Happy DOM options.
124
- */
125
- interface HappyDOMOptions {
126
- width?: number;
127
- height?: number;
128
- url?: string;
129
- settings?: {
130
- disableJavaScriptEvaluation?: boolean;
131
- disableJavaScriptFileLoading?: boolean;
132
- disableCSSFileLoading?: boolean;
133
- disableIframePageLoading?: boolean;
134
- disableComputedStyleRendering?: boolean;
135
- enableFileSystemHttpRequests?: boolean;
136
- navigator?: {
137
- userAgent?: string;
138
- };
139
- device?: {
140
- prefersColorScheme?: string;
141
- mediaType?: string;
142
- };
143
- };
144
- }
145
-
146
146
  interface EnvironmentReturn {
147
147
  teardown: (global: any) => Awaitable<void>;
148
148
  }