vitest 3.2.4 → 4.0.0-beta.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 (50) hide show
  1. package/dist/browser.d.ts +3 -5
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.DfmxU-tU.js → base.Bj3pWTr1.js} +1 -1
  4. package/dist/chunks/browser.d.DP0ACFkh.d.ts +18 -0
  5. package/dist/chunks/{cac.Cb-PYCCB.js → cac.CVVvMokL.js} +8 -19
  6. package/dist/chunks/{cli-api.BkDphVBG.js → cli-api.BUkNuHvl.js} +23 -22
  7. package/dist/chunks/{config.d.D2ROskhv.d.ts → config.d.HJdfX-8k.d.ts} +1 -2
  8. package/dist/chunks/{coverage.DL5VHqXY.js → coverage.BjMqihzx.js} +58 -37
  9. package/dist/chunks/{defaults.B7q_naMc.js → defaults.CXFFjsi8.js} +2 -42
  10. package/dist/chunks/environment.d.CUq4cUgQ.d.ts +44 -0
  11. package/dist/chunks/{global.d.MAmajcmJ.d.ts → global.d.CVbXEflG.d.ts} +7 -29
  12. package/dist/chunks/{globals.DEHgCU4V.js → globals.Cxal6MLI.js} +1 -1
  13. package/dist/chunks/{index.CdQS2e2Q.js → index.BWf_gE5n.js} +0 -2
  14. package/dist/chunks/{index.BCWujgDG.js → index.CJvUWPky.js} +1 -1
  15. package/dist/chunks/{index.CwejwG0H.js → index.D-VkfKhf.js} +2 -2
  16. package/dist/chunks/{index.VByaPkjc.js → index.a-yuRg2G.js} +223 -236
  17. package/dist/chunks/plugin.d.NmsBIHuT.d.ts +9 -0
  18. package/dist/chunks/{reporters.d.BFLkQcL6.d.ts → reporters.d.BbsDWlO9.d.ts} +2191 -2211
  19. package/dist/chunks/{rpc.-pEldfrD.js → rpc.CsFtxqeq.js} +4 -4
  20. package/dist/chunks/{runBaseTests.9Ij9_de-.js → runBaseTests.BC7ZIH5L.js} +4 -4
  21. package/dist/chunks/{setup-common.Dd054P77.js → setup-common.D7ZqXFx-.js} +1 -1
  22. package/dist/chunks/{worker.d.1GmBbd7G.d.ts → worker.d.COAQvn4k.d.ts} +6 -19
  23. package/dist/chunks/{worker.d.CKwWzBSj.d.ts → worker.d.CVn8WGlF.d.ts} +1 -1
  24. package/dist/cli.js +9 -9
  25. package/dist/config.cjs +2 -49
  26. package/dist/config.d.ts +36 -30
  27. package/dist/config.js +2 -8
  28. package/dist/coverage.d.ts +15 -9
  29. package/dist/coverage.js +6 -5
  30. package/dist/environments.d.ts +2 -3
  31. package/dist/execute.d.ts +3 -5
  32. package/dist/index.d.ts +24 -181
  33. package/dist/index.js +1 -1
  34. package/dist/node.d.ts +37 -28
  35. package/dist/node.js +13 -19
  36. package/dist/reporters.d.ts +9 -9
  37. package/dist/reporters.js +12 -12
  38. package/dist/runners.d.ts +1 -2
  39. package/dist/runners.js +10 -2
  40. package/dist/worker.js +1 -1
  41. package/dist/workers/forks.js +1 -1
  42. package/dist/workers/runVmTests.js +4 -4
  43. package/dist/workers/threads.js +1 -1
  44. package/dist/workers.d.ts +4 -7
  45. package/dist/workers.js +2 -2
  46. package/globals.d.ts +17 -17
  47. package/package.json +12 -12
  48. package/dist/chunks/environment.d.cL3nLXbE.d.ts +0 -119
  49. package/dist/chunks/vite.d.CMLlLIFP.d.ts +0 -25
  50. package/dist/chunks/{typechecker.DRKU1-1g.js → typechecker.CVytUJuF.js} +26 -26
package/dist/workers.d.ts CHANGED
@@ -1,15 +1,12 @@
1
- import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.1GmBbd7G.js';
1
+ import { W as WorkerGlobalState, C as ContextRPC, B as BirpcOptions, R as RuntimeRPC } from './chunks/worker.d.COAQvn4k.js';
2
2
  import { Awaitable } from '@vitest/utils';
3
3
  import * as v8 from 'v8';
4
- import { a as SerializedConfig } from './chunks/config.d.D2ROskhv.js';
5
- import { W as WorkerContext } from './chunks/worker.d.CKwWzBSj.js';
4
+ import { a as SerializedConfig } from './chunks/config.d.HJdfX-8k.js';
5
+ import { W as WorkerContext } from './chunks/worker.d.CVn8WGlF.js';
6
6
  import '@vitest/runner';
7
- import 'vite-node';
8
- import './chunks/environment.d.cL3nLXbE.js';
9
- import 'vitest/optional-types.js';
7
+ import './chunks/environment.d.CUq4cUgQ.js';
10
8
  import '@vitest/snapshot';
11
9
  import '@vitest/pretty-format';
12
- import '@vitest/snapshot/environment';
13
10
  import '@vitest/utils/diff';
14
11
  import 'node:worker_threads';
15
12
 
package/dist/workers.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { p as provideWorkerState } from './chunks/utils.XdZDrNZV.js';
2
2
  export { collect as collectVitestWorkerTests, run as runVitestWorker } from './worker.js';
3
- export { r as runBaseTests } from './chunks/base.DfmxU-tU.js';
3
+ export { r as runBaseTests } from './chunks/base.Bj3pWTr1.js';
4
4
  export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './chunks/utils.CAioKnHs.js';
5
5
  export { r as runVmTests } from './chunks/vm.BThCzidc.js';
6
6
  import '@vitest/utils';
@@ -14,7 +14,7 @@ import './chunks/index.CmSc2RE5.js';
14
14
  import 'node:console';
15
15
  import './chunks/inspector.C914Efll.js';
16
16
  import 'node:module';
17
- import './chunks/rpc.-pEldfrD.js';
17
+ import './chunks/rpc.CsFtxqeq.js';
18
18
  import './chunks/index.B521nVV-.js';
19
19
  import './chunks/execute.B7h3T_Hc.js';
20
20
  import 'node:vm';
package/globals.d.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  declare global {
2
- const suite: typeof import('vitest')['suite']
3
- const test: typeof import('vitest')['test']
4
- const chai: typeof import("vitest")["chai"]
5
- const describe: typeof import('vitest')['describe']
6
- const it: typeof import('vitest')['it']
7
- const expectTypeOf: typeof import('vitest')['expectTypeOf']
8
- const assertType: typeof import('vitest')['assertType']
9
- const expect: typeof import('vitest')['expect']
10
- const assert: typeof import('vitest')['assert']
11
- const vitest: typeof import('vitest')['vitest']
12
- const vi: typeof import('vitest')['vitest']
13
- const beforeAll: typeof import('vitest')['beforeAll']
14
- const afterAll: typeof import('vitest')['afterAll']
15
- const beforeEach: typeof import('vitest')['beforeEach']
16
- const afterEach: typeof import('vitest')['afterEach']
17
- const onTestFailed: typeof import('vitest')['onTestFailed']
18
- const onTestFinished: typeof import('vitest')['onTestFinished']
2
+ let suite: typeof import('vitest')['suite']
3
+ let test: typeof import('vitest')['test']
4
+ let chai: typeof import("vitest")["chai"]
5
+ let describe: typeof import('vitest')['describe']
6
+ let it: typeof import('vitest')['it']
7
+ let expectTypeOf: typeof import('vitest')['expectTypeOf']
8
+ let assertType: typeof import('vitest')['assertType']
9
+ let expect: typeof import('vitest')['expect']
10
+ let assert: typeof import('vitest')['assert']
11
+ let vitest: typeof import('vitest')['vitest']
12
+ let vi: typeof import('vitest')['vitest']
13
+ let beforeAll: typeof import('vitest')['beforeAll']
14
+ let afterAll: typeof import('vitest')['afterAll']
15
+ let beforeEach: typeof import('vitest')['beforeEach']
16
+ let afterEach: typeof import('vitest')['afterEach']
17
+ let onTestFailed: typeof import('vitest')['onTestFailed']
18
+ let onTestFinished: typeof import('vitest')['onTestFinished']
19
19
  }
20
20
  export {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "3.2.4",
4
+ "version": "4.0.0-beta.2",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -119,8 +119,8 @@
119
119
  "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0",
120
120
  "happy-dom": "*",
121
121
  "jsdom": "*",
122
- "@vitest/browser": "3.2.4",
123
- "@vitest/ui": "3.2.4"
122
+ "@vitest/ui": "4.0.0-beta.2",
123
+ "@vitest/browser": "4.0.0-beta.2"
124
124
  },
125
125
  "peerDependenciesMeta": {
126
126
  "@edge-runtime/vm": {
@@ -159,16 +159,16 @@
159
159
  "tinyglobby": "^0.2.14",
160
160
  "tinypool": "^1.1.1",
161
161
  "tinyrainbow": "^2.0.0",
162
- "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0",
162
+ "vite": "^6.0.0 || ^7.0.0-0",
163
163
  "why-is-node-running": "^2.3.0",
164
- "@vitest/expect": "3.2.4",
165
- "@vitest/mocker": "3.2.4",
166
- "@vitest/snapshot": "3.2.4",
167
- "@vitest/runner": "3.2.4",
168
- "@vitest/pretty-format": "^3.2.4",
169
- "@vitest/spy": "3.2.4",
170
- "vite-node": "3.2.4",
171
- "@vitest/utils": "3.2.4"
164
+ "@vitest/expect": "4.0.0-beta.2",
165
+ "@vitest/snapshot": "4.0.0-beta.2",
166
+ "@vitest/mocker": "4.0.0-beta.2",
167
+ "@vitest/pretty-format": "^4.0.0-beta.2",
168
+ "@vitest/runner": "4.0.0-beta.2",
169
+ "@vitest/utils": "4.0.0-beta.2",
170
+ "@vitest/spy": "4.0.0-beta.2",
171
+ "vite-node": "4.0.0-beta.2"
172
172
  },
173
173
  "devDependencies": {
174
174
  "@ampproject/remapping": "^2.3.0",
@@ -1,119 +0,0 @@
1
- import { happyDomTypes, jsdomTypes } from 'vitest/optional-types.js';
2
-
3
- type Awaitable<T> = T | PromiseLike<T>;
4
- type Nullable<T> = T | null | undefined;
5
- type Arrayable<T> = T | Array<T>;
6
- type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
7
- type MutableArray<T extends readonly any[]> = { -readonly [k in keyof T] : T[k] };
8
- interface Constructable {
9
- new (...args: any[]): any;
10
- }
11
- type TransformMode = "web" | "ssr";
12
- /** @deprecated not used */
13
- interface ModuleCache {
14
- promise?: Promise<any>;
15
- exports?: any;
16
- code?: string;
17
- }
18
- interface AfterSuiteRunMeta {
19
- coverage?: unknown;
20
- testFiles: string[];
21
- transformMode: TransformMode | "browser";
22
- projectName?: string;
23
- }
24
- interface UserConsoleLog {
25
- content: string;
26
- origin?: string;
27
- browser?: boolean;
28
- type: "stdout" | "stderr";
29
- taskId?: string;
30
- time: number;
31
- size: number;
32
- }
33
- interface ModuleGraphData {
34
- graph: Record<string, string[]>;
35
- externalized: string[];
36
- inlined: string[];
37
- }
38
- interface ProvidedContext {}
39
- // These need to be compatible with Tinyrainbow's bg-colors, and CSS's background-color
40
- type LabelColor = "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white";
41
-
42
- type HappyDOMOptions = Omit<NonNullable<ConstructorParameters<typeof happyDomTypes.Window>[0]>, "console">;
43
-
44
- type JSDOMOptions = ConstructorOptionsOverride & Omit<jsdomTypes.ConstructorOptions, keyof ConstructorOptionsOverride>;
45
- interface ConstructorOptionsOverride {
46
- /**
47
- * The html content for the test.
48
- *
49
- * @default '<!DOCTYPE html>'
50
- */
51
- html?: string | ArrayBufferLike;
52
- /**
53
- * userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
54
- *
55
- * @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
56
- */
57
- userAgent?: string;
58
- /**
59
- * url sets the value returned by window.location, document.URL, and document.documentURI,
60
- * and affects things like resolution of relative URLs within the document
61
- * and the same-origin restrictions and referrer used while fetching subresources.
62
- *
63
- * @default 'http://localhost:3000'.
64
- */
65
- url?: string;
66
- /**
67
- * Enable console?
68
- *
69
- * @default false
70
- */
71
- console?: boolean;
72
- /**
73
- * jsdom does not have the capability to render visual content, and will act like a headless browser by default.
74
- * It provides hints to web pages through APIs such as document.hidden that their content is not visible.
75
- *
76
- * When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
77
- * content.
78
- *
79
- * @default true
80
- */
81
- pretendToBeVisual?: boolean;
82
- /**
83
- * Enable CookieJar
84
- *
85
- * @default false
86
- */
87
- cookieJar?: boolean;
88
- resources?: "usable";
89
- }
90
-
91
- interface EnvironmentReturn {
92
- teardown: (global: any) => Awaitable<void>;
93
- }
94
- interface VmEnvironmentReturn {
95
- getVmContext: () => {
96
- [key: string]: any
97
- };
98
- teardown: () => Awaitable<void>;
99
- }
100
- interface Environment {
101
- name: string;
102
- transformMode: "web" | "ssr";
103
- setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
104
- setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
105
- }
106
- interface EnvironmentOptions {
107
- /**
108
- * jsdom options.
109
- */
110
- jsdom?: JSDOMOptions;
111
- happyDOM?: HappyDOMOptions;
112
- [x: string]: unknown;
113
- }
114
- interface ResolvedTestEnvironment {
115
- environment: Environment;
116
- options: Record<string, any> | null;
117
- }
118
-
119
- export type { AfterSuiteRunMeta as A, Constructable as C, Environment as E, HappyDOMOptions as H, JSDOMOptions as J, LabelColor as L, ModuleGraphData as M, Nullable as N, ProvidedContext as P, ResolvedTestEnvironment as R, TransformMode as T, UserConsoleLog as U, VmEnvironmentReturn as V, EnvironmentReturn as a, Awaitable as b, Arrayable as c, ArgumentsType as d, MutableArray as e, EnvironmentOptions as f, ModuleCache as g };
@@ -1,25 +0,0 @@
1
- import { HookHandler } from 'vite';
2
- import { V as Vitest, T as TestProject, b as TestProjectConfiguration, I as InlineConfig } from './reporters.d.BFLkQcL6.js';
3
-
4
- interface VitestPluginContext {
5
- vitest: Vitest;
6
- project: TestProject;
7
- injectTestProjects: (config: TestProjectConfiguration | TestProjectConfiguration[]) => Promise<TestProject[]>;
8
- }
9
-
10
- /* eslint-disable unused-imports/no-unused-vars */
11
-
12
- type VitestInlineConfig = InlineConfig;
13
- declare module "vite" {
14
- interface UserConfig {
15
- /**
16
- * Options for Vitest
17
- */
18
- test?: VitestInlineConfig;
19
- }
20
- interface Plugin<A = any> {
21
- configureVitest?: HookHandler<(context: VitestPluginContext) => void>;
22
- }
23
- }
24
-
25
- export type { VitestPluginContext as V };
@@ -8,6 +8,32 @@ import { getTests, generateHash, calculateSuiteHash, someTasksAreOnly, interpret
8
8
  import '@vitest/utils';
9
9
  import { parseAstAsync } from 'vite';
10
10
 
11
+ const REGEXP_WRAP_PREFIX = "$$vitest:";
12
+ function getOutputFile(config, reporter) {
13
+ if (!config?.outputFile) return;
14
+ if (typeof config.outputFile === "string") return config.outputFile;
15
+ return config.outputFile[reporter];
16
+ }
17
+ /**
18
+ * Prepares `SerializedConfig` for serialization, e.g. `node:v8.serialize`
19
+ */
20
+ function wrapSerializableConfig(config) {
21
+ let testNamePattern = config.testNamePattern;
22
+ let defines = config.defines;
23
+ // v8 serialize does not support regex
24
+ if (testNamePattern && typeof testNamePattern !== "string") testNamePattern = `${REGEXP_WRAP_PREFIX}${testNamePattern.toString()}`;
25
+ // v8 serialize drops properties with undefined value
26
+ if (defines) defines = {
27
+ keys: Object.keys(defines),
28
+ original: defines
29
+ };
30
+ return {
31
+ ...config,
32
+ testNamePattern,
33
+ defines
34
+ };
35
+ }
36
+
11
37
  function hasFailedSnapshot(suite) {
12
38
  return getTests(suite).some((s) => {
13
39
  return s.result?.errors?.some((e) => typeof e?.message === "string" && e.message.match(/Snapshot .* mismatched/));
@@ -71,32 +97,6 @@ function convertTasksToEvents(file, onTask) {
71
97
  };
72
98
  }
73
99
 
74
- const REGEXP_WRAP_PREFIX = "$$vitest:";
75
- function getOutputFile(config, reporter) {
76
- if (!config?.outputFile) return;
77
- if (typeof config.outputFile === "string") return config.outputFile;
78
- return config.outputFile[reporter];
79
- }
80
- /**
81
- * Prepares `SerializedConfig` for serialization, e.g. `node:v8.serialize`
82
- */
83
- function wrapSerializableConfig(config) {
84
- let testNamePattern = config.testNamePattern;
85
- let defines = config.defines;
86
- // v8 serialize does not support regex
87
- if (testNamePattern && typeof testNamePattern !== "string") testNamePattern = `${REGEXP_WRAP_PREFIX}${testNamePattern.toString()}`;
88
- // v8 serialize drops properties with undefined value
89
- if (defines) defines = {
90
- keys: Object.keys(defines),
91
- original: defines
92
- };
93
- return {
94
- ...config,
95
- testNamePattern,
96
- defines
97
- };
98
- }
99
-
100
100
  // AST walker module for ESTree compatible trees
101
101
 
102
102