vitest 3.0.8 → 3.0.9

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 (60) hide show
  1. package/dist/browser.d.ts +12 -23
  2. package/dist/browser.js +2 -2
  3. package/dist/chunks/{base.XvKTsMeK.js → base.DV59CbtV.js} +1 -1
  4. package/dist/chunks/{benchmark.Cdu9hjj4.js → benchmark.DL72EVN-.js} +1 -1
  5. package/dist/chunks/{benchmark.CFFwLv-O.d.ts → benchmark.d.BwvBVTda.d.ts} +11 -11
  6. package/dist/chunks/{cac.VN5q-TPC.js → cac.CeVHgzve.js} +5 -5
  7. package/dist/chunks/{cli-api.Dis64jtY.js → cli-api.Ckwz_xSb.js} +13 -8
  8. package/dist/chunks/config.d.DevWltVl.d.ts +218 -0
  9. package/dist/chunks/{constants.fzPh7AOq.js → constants.DTYd6dNH.js} +1 -1
  10. package/dist/chunks/{coverage.DnNIv-kJ.js → coverage.A3sS5-Wm.js} +1 -29
  11. package/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
  12. package/dist/chunks/{resolveConfig.L1_HR0_0.js → coverage.gV8doR2Y.js} +496 -127
  13. package/dist/chunks/{creator.2CFRE1Yx.js → creator.BsBnpTzI.js} +1 -1
  14. package/dist/chunks/defaults.C2Ndd9wx.js +119 -0
  15. package/dist/chunks/env.D4Lgay0q.js +8 -0
  16. package/dist/chunks/environment.d.C8UItCbf.d.ts +170 -0
  17. package/dist/chunks/global.d.Cg2sEPIm.d.ts +127 -0
  18. package/dist/chunks/{globals.CydvVTgC.js → globals.BEpDe-k3.js} +4 -4
  19. package/dist/chunks/{index.B7vJpkTD.js → index.B8tIoLPT.js} +6 -1
  20. package/dist/chunks/{index.CNRemkXW.js → index.D7Ny8f_s.js} +2 -2
  21. package/dist/chunks/{index.BmFgJtkv.js → index.uXkkC4xl.js} +1 -2
  22. package/dist/chunks/{mocker.cRtM890J.d.ts → mocker.d.BE_2ls6u.d.ts} +6 -6
  23. package/dist/chunks/reporters.d.CqBhtcTq.d.ts +3006 -0
  24. package/dist/chunks/{runBaseTests.DnaAUBKD.js → runBaseTests.BVrL_ow3.js} +8 -8
  25. package/dist/chunks/{setup-common.Uaw6Zgv9.js → setup-common.CPvtqi8q.js} +25 -2
  26. package/dist/chunks/{suite.qtkXWc6R.d.ts → suite.d.FvehnV49.d.ts} +1 -1
  27. package/dist/chunks/{typechecker.cZ0LjdSi.js → typechecker.BlF3eHsb.js} +2 -7
  28. package/dist/chunks/{vi.B5EKKJdE.js → vi.nSCvwQ7l.js} +3 -3
  29. package/dist/chunks/vite.d.BUZTGxQ3.d.ts +11 -0
  30. package/dist/chunks/{worker.BmVno_ab.d.ts → worker.d.C58isfFm.d.ts} +62 -62
  31. package/dist/chunks/{worker.BT4v-DKx.d.ts → worker.d.CSFlSYJg.d.ts} +2 -2
  32. package/dist/cli.js +2 -2
  33. package/dist/config.d.ts +48 -45
  34. package/dist/config.js +6 -123
  35. package/dist/coverage.d.ts +82 -79
  36. package/dist/coverage.js +19 -469
  37. package/dist/environments.d.ts +11 -11
  38. package/dist/execute.d.ts +109 -109
  39. package/dist/index.d.ts +414 -412
  40. package/dist/index.js +3 -3
  41. package/dist/node.d.ts +51 -48
  42. package/dist/node.js +13 -10
  43. package/dist/reporters.d.ts +7 -4
  44. package/dist/reporters.js +3 -2
  45. package/dist/runners.d.ts +28 -28
  46. package/dist/runners.js +2 -3
  47. package/dist/snapshot.d.ts +2 -2
  48. package/dist/suite.d.ts +2 -2
  49. package/dist/suite.js +1 -1
  50. package/dist/workers/forks.js +1 -1
  51. package/dist/workers/runVmTests.js +8 -8
  52. package/dist/workers/threads.js +1 -1
  53. package/dist/workers.d.ts +13 -13
  54. package/dist/workers.js +1 -1
  55. package/package.json +11 -11
  56. package/dist/chunks/config.BCv-fVdT.d.ts +0 -215
  57. package/dist/chunks/environment.d8YfPkTm.d.ts +0 -173
  58. package/dist/chunks/global.CnI8_G5V.d.ts +0 -133
  59. package/dist/chunks/reporters.66aFHiyX.d.ts +0 -3051
  60. package/dist/chunks/vite.BCQa3xFG.d.ts +0 -11
@@ -1,215 +0,0 @@
1
- import { PrettyFormatOptions } from '@vitest/pretty-format';
2
- import { SequenceHooks, SequenceSetupFiles } from '@vitest/runner';
3
- import { SnapshotUpdateState } from '@vitest/snapshot';
4
- import { SnapshotEnvironment } from '@vitest/snapshot/environment';
5
- import { SerializedDiffOptions } from '@vitest/utils/diff';
6
-
7
- /**
8
- * Names of clock methods that may be faked by install.
9
- */
10
- type FakeMethod =
11
- | "setTimeout"
12
- | "clearTimeout"
13
- | "setImmediate"
14
- | "clearImmediate"
15
- | "setInterval"
16
- | "clearInterval"
17
- | "Date"
18
- | "nextTick"
19
- | "hrtime"
20
- | "requestAnimationFrame"
21
- | "cancelAnimationFrame"
22
- | "requestIdleCallback"
23
- | "cancelIdleCallback"
24
- | "performance"
25
- | "queueMicrotask";
26
-
27
- interface FakeTimerInstallOpts {
28
- /**
29
- * Installs fake timers with the specified unix epoch (default: 0)
30
- */
31
- now?: number | Date | undefined;
32
-
33
- /**
34
- * An array with names of global methods and APIs to fake.
35
- * For instance, `vi.useFakeTimer({ toFake: ['setTimeout', 'performance'] })` will fake only `setTimeout()` and `performance.now()`
36
- * @default everything available globally except `nextTick`
37
- */
38
- toFake?: FakeMethod[] | undefined;
39
-
40
- /**
41
- * The maximum number of timers that will be run when calling runAll()
42
- * @default 10000
43
- */
44
- loopLimit?: number | undefined;
45
-
46
- /**
47
- * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
48
- * 20ms for every 20ms change in the real system time) (default: false)
49
- */
50
- shouldAdvanceTime?: boolean | undefined;
51
-
52
- /**
53
- * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
54
- * in the real system time (default: 20)
55
- */
56
- advanceTimeDelta?: number | undefined;
57
-
58
- /**
59
- * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers.
60
- * @default true
61
- */
62
- shouldClearNativeTimers?: boolean | undefined;
63
-
64
- /**
65
- * Don't throw error when asked to fake timers that are not present.
66
- * @default false
67
- */
68
- ignoreMissingTimers?: boolean | undefined;
69
- }
70
-
71
- /**
72
- * Config that tests have access to.
73
- */
74
- interface SerializedConfig {
75
- name: string | undefined;
76
- globals: boolean;
77
- base: string | undefined;
78
- snapshotEnvironment?: string;
79
- disableConsoleIntercept: boolean | undefined;
80
- runner: string | undefined;
81
- isolate: boolean;
82
- mode: 'test' | 'benchmark';
83
- bail: number | undefined;
84
- environmentOptions?: Record<string, any>;
85
- root: string;
86
- setupFiles: string[];
87
- passWithNoTests: boolean;
88
- testNamePattern: RegExp | undefined;
89
- allowOnly: boolean;
90
- testTimeout: number;
91
- hookTimeout: number;
92
- clearMocks: boolean;
93
- mockReset: boolean;
94
- restoreMocks: boolean;
95
- unstubGlobals: boolean;
96
- unstubEnvs: boolean;
97
- fakeTimers: FakeTimerInstallOpts;
98
- maxConcurrency: number;
99
- defines: Record<string, any>;
100
- expect: {
101
- requireAssertions?: boolean;
102
- poll?: {
103
- timeout?: number;
104
- interval?: number;
105
- };
106
- };
107
- printConsoleTrace: boolean | undefined;
108
- sequence: {
109
- shuffle?: boolean;
110
- concurrent?: boolean;
111
- seed: number;
112
- hooks: SequenceHooks;
113
- setupFiles: SequenceSetupFiles;
114
- };
115
- poolOptions: {
116
- forks: {
117
- singleFork: boolean;
118
- isolate: boolean;
119
- };
120
- threads: {
121
- singleThread: boolean;
122
- isolate: boolean;
123
- };
124
- vmThreads: {
125
- singleThread: boolean;
126
- };
127
- vmForks: {
128
- singleFork: boolean;
129
- };
130
- };
131
- deps: {
132
- web: {
133
- transformAssets?: boolean;
134
- transformCss?: boolean;
135
- transformGlobPattern?: RegExp | RegExp[];
136
- };
137
- optimizer: {
138
- web: {
139
- enabled: boolean;
140
- };
141
- ssr: {
142
- enabled: boolean;
143
- };
144
- };
145
- interopDefault: boolean | undefined;
146
- moduleDirectories: string[] | undefined;
147
- };
148
- snapshotOptions: {
149
- updateSnapshot: SnapshotUpdateState;
150
- expand: boolean | undefined;
151
- snapshotFormat: PrettyFormatOptions | undefined;
152
- /**
153
- * only exists for tests, not available in the main process
154
- */
155
- snapshotEnvironment: SnapshotEnvironment;
156
- };
157
- pool: string;
158
- snapshotSerializers: string[];
159
- chaiConfig: {
160
- includeStack?: boolean;
161
- showDiff?: boolean;
162
- truncateThreshold?: number;
163
- } | undefined;
164
- diff: string | SerializedDiffOptions | undefined;
165
- retry: number;
166
- includeTaskLocation: boolean | undefined;
167
- inspect: boolean | string | undefined;
168
- inspectBrk: boolean | string | undefined;
169
- inspector: {
170
- enabled?: boolean;
171
- port?: number;
172
- host?: string;
173
- waitForDebugger?: boolean;
174
- };
175
- watch: boolean;
176
- env: Record<string, any>;
177
- browser: {
178
- name: string;
179
- headless: boolean;
180
- isolate: boolean;
181
- fileParallelism: boolean;
182
- ui: boolean;
183
- viewport: {
184
- width: number;
185
- height: number;
186
- };
187
- locators: {
188
- testIdAttribute: string;
189
- };
190
- screenshotFailures: boolean;
191
- };
192
- standalone: boolean;
193
- logHeapUsage: boolean | undefined;
194
- coverage: SerializedCoverageConfig;
195
- benchmark?: {
196
- includeSamples: boolean;
197
- };
198
- }
199
- interface SerializedCoverageConfig {
200
- provider: 'istanbul' | 'v8' | 'custom' | undefined;
201
- reportsDirectory: string;
202
- htmlReporter: {
203
- subdir: string | undefined;
204
- } | undefined;
205
- enabled: boolean;
206
- customProviderModule: string | undefined;
207
- }
208
- type RuntimeConfig = Pick<SerializedConfig, 'allowOnly' | 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'mockReset' | 'restoreMocks' | 'fakeTimers' | 'maxConcurrency' | 'expect' | 'printConsoleTrace'> & {
209
- sequence?: {
210
- hooks?: SequenceHooks;
211
- };
212
- };
213
- type RuntimeOptions = Partial<RuntimeConfig>;
214
-
215
- export type { FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedCoverageConfig as S, SerializedConfig as a, RuntimeConfig as b };
@@ -1,173 +0,0 @@
1
- type Awaitable<T> = T | PromiseLike<T>;
2
- type Nullable<T> = T | null | undefined;
3
- type Arrayable<T> = T | Array<T>;
4
- type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
5
- type MutableArray<T extends readonly any[]> = {
6
- -readonly [k in keyof T]: T[k];
7
- };
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
- }
40
-
41
- /**
42
- * Happy DOM options.
43
- */
44
- interface HappyDOMOptions {
45
- width?: number;
46
- height?: number;
47
- url?: string;
48
- settings?: {
49
- disableJavaScriptEvaluation?: boolean;
50
- disableJavaScriptFileLoading?: boolean;
51
- disableCSSFileLoading?: boolean;
52
- disableIframePageLoading?: boolean;
53
- disableComputedStyleRendering?: boolean;
54
- enableFileSystemHttpRequests?: boolean;
55
- navigator?: {
56
- userAgent?: string;
57
- };
58
- device?: {
59
- prefersColorScheme?: string;
60
- mediaType?: string;
61
- };
62
- };
63
- }
64
-
65
- interface JSDOMOptions {
66
- /**
67
- * The html content for the test.
68
- *
69
- * @default '<!DOCTYPE html>'
70
- */
71
- html?: string | ArrayBufferLike;
72
- /**
73
- * referrer just affects the value read from document.referrer.
74
- * It defaults to no referrer (which reflects as the empty string).
75
- */
76
- referrer?: string;
77
- /**
78
- * userAgent affects the value read from navigator.userAgent, as well as the User-Agent header sent while fetching subresources.
79
- *
80
- * @default `Mozilla/5.0 (${process.platform}) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/${jsdomVersion}`
81
- */
82
- userAgent?: string;
83
- /**
84
- * url sets the value returned by window.location, document.URL, and document.documentURI,
85
- * and affects things like resolution of relative URLs within the document
86
- * and the same-origin restrictions and referrer used while fetching subresources.
87
- *
88
- * @default 'http://localhost:3000'.
89
- */
90
- url?: string;
91
- /**
92
- * contentType affects the value read from document.contentType, and how the document is parsed: as HTML or as XML.
93
- * Values that are not "text/html" or an XML mime type will throw.
94
- *
95
- * @default 'text/html'.
96
- */
97
- contentType?: string;
98
- /**
99
- * The maximum size in code units for the separate storage areas used by localStorage and sessionStorage.
100
- * Attempts to store data larger than this limit will cause a DOMException to be thrown. By default, it is set
101
- * to 5,000,000 code units per origin, as inspired by the HTML specification.
102
- *
103
- * @default 5_000_000
104
- */
105
- storageQuota?: number;
106
- /**
107
- * Enable console?
108
- *
109
- * @default false
110
- */
111
- console?: boolean;
112
- /**
113
- * jsdom does not have the capability to render visual content, and will act like a headless browser by default.
114
- * It provides hints to web pages through APIs such as document.hidden that their content is not visible.
115
- *
116
- * When the `pretendToBeVisual` option is set to `true`, jsdom will pretend that it is rendering and displaying
117
- * content.
118
- *
119
- * @default true
120
- */
121
- pretendToBeVisual?: boolean;
122
- /**
123
- * `includeNodeLocations` preserves the location info produced by the HTML parser,
124
- * allowing you to retrieve it with the nodeLocation() method (described below).
125
- *
126
- * It defaults to false to give the best performance,
127
- * and cannot be used with an XML content type since our XML parser does not support location info.
128
- *
129
- * @default false
130
- */
131
- includeNodeLocations?: boolean | undefined;
132
- /**
133
- * @default 'dangerously'
134
- */
135
- runScripts?: 'dangerously' | 'outside-only';
136
- /**
137
- * Enable CookieJar
138
- *
139
- * @default false
140
- */
141
- cookieJar?: boolean;
142
- resources?: 'usable';
143
- }
144
-
145
- interface EnvironmentReturn {
146
- teardown: (global: any) => Awaitable<void>;
147
- }
148
- interface VmEnvironmentReturn {
149
- getVmContext: () => {
150
- [key: string]: any;
151
- };
152
- teardown: () => Awaitable<void>;
153
- }
154
- interface Environment {
155
- name: string;
156
- transformMode: 'web' | 'ssr';
157
- setupVM?: (options: Record<string, any>) => Awaitable<VmEnvironmentReturn>;
158
- setup: (global: any, options: Record<string, any>) => Awaitable<EnvironmentReturn>;
159
- }
160
- interface EnvironmentOptions {
161
- /**
162
- * jsdom options.
163
- */
164
- jsdom?: JSDOMOptions;
165
- happyDOM?: HappyDOMOptions;
166
- [x: string]: unknown;
167
- }
168
- interface ResolvedTestEnvironment {
169
- environment: Environment;
170
- options: Record<string, any> | null;
171
- }
172
-
173
- export type { AfterSuiteRunMeta as A, Constructable as C, Environment as E, HappyDOMOptions as H, JSDOMOptions as J, 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,133 +0,0 @@
1
- import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
- import { Plugin } from '@vitest/pretty-format';
3
- import { SnapshotState } from '@vitest/snapshot';
4
- import { B as BenchmarkResult } from './benchmark.CFFwLv-O.js';
5
- import { U as UserConsoleLog } from './environment.d8YfPkTm.js';
6
-
7
- type RawErrsMap = Map<string, TscErrorInfo[]>;
8
- interface TscErrorInfo {
9
- filePath: string;
10
- errCode: number;
11
- errMsg: string;
12
- line: number;
13
- column: number;
14
- }
15
- interface CollectLineNumbers {
16
- target: number;
17
- next: number;
18
- prev?: number;
19
- }
20
- type CollectLines = {
21
- [key in keyof CollectLineNumbers]: string;
22
- };
23
- interface RootAndTarget {
24
- root: string;
25
- targetAbsPath: string;
26
- }
27
- type Context = RootAndTarget & {
28
- rawErrsMap: RawErrsMap;
29
- openedDirs: Set<string>;
30
- lastActivePath?: string;
31
- };
32
-
33
- declare global {
34
- namespace Chai {
35
- interface Assertion {
36
- containSubset: (expected: any) => Assertion;
37
- }
38
- interface Assert {
39
- containSubset: (val: any, exp: any, msg?: string) => void;
40
- }
41
- }
42
- }
43
- interface SnapshotMatcher<T> {
44
- <U extends {
45
- [P in keyof T]: any;
46
- }>(snapshot: Partial<U>, message?: string): void;
47
- (message?: string): void;
48
- }
49
- interface InlineSnapshotMatcher<T> {
50
- <U extends {
51
- [P in keyof T]: any;
52
- }>(properties: Partial<U>, snapshot?: string, message?: string): void;
53
- (message?: string): void;
54
- }
55
- declare module '@vitest/expect' {
56
- interface MatcherState {
57
- environment: string;
58
- snapshotState: SnapshotState;
59
- }
60
- interface ExpectPollOptions {
61
- interval?: number;
62
- timeout?: number;
63
- message?: string;
64
- }
65
- interface ExpectStatic {
66
- unreachable: (message?: string) => never;
67
- soft: <T>(actual: T, message?: string) => Assertion<T>;
68
- poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
69
- addEqualityTesters: (testers: Array<Tester>) => void;
70
- assertions: (expected: number) => void;
71
- hasAssertions: () => void;
72
- addSnapshotSerializer: (plugin: Plugin) => void;
73
- }
74
- interface Assertion<T> {
75
- matchSnapshot: SnapshotMatcher<T>;
76
- toMatchSnapshot: SnapshotMatcher<T>;
77
- toMatchInlineSnapshot: InlineSnapshotMatcher<T>;
78
- /**
79
- * Checks that an error thrown by a function matches a previously recorded snapshot.
80
- *
81
- * @param message - Optional custom error message.
82
- *
83
- * @example
84
- * expect(functionWithError).toThrowErrorMatchingSnapshot();
85
- */
86
- toThrowErrorMatchingSnapshot: (message?: string) => void;
87
- /**
88
- * Checks that an error thrown by a function matches an inline snapshot within the test file.
89
- * Useful for keeping snapshots close to the test code.
90
- *
91
- * @param snapshot - Optional inline snapshot string to match.
92
- * @param message - Optional custom error message.
93
- *
94
- * @example
95
- * const throwError = () => { throw new Error('Error occurred') };
96
- * expect(throwError).toThrowErrorMatchingInlineSnapshot(`"Error occurred"`);
97
- */
98
- toThrowErrorMatchingInlineSnapshot: (snapshot?: string, message?: string) => void;
99
- /**
100
- * Compares the received value to a snapshot saved in a specified file.
101
- * Useful for cases where snapshot content is large or needs to be shared across tests.
102
- *
103
- * @param filepath - Path to the snapshot file.
104
- * @param message - Optional custom error message.
105
- *
106
- * @example
107
- * await expect(largeData).toMatchFileSnapshot('path/to/snapshot.json');
108
- */
109
- toMatchFileSnapshot: (filepath: string, message?: string) => Promise<void>;
110
- }
111
- }
112
- declare module '@vitest/runner' {
113
- interface TestContext {
114
- expect: ExpectStatic;
115
- }
116
- interface TaskMeta {
117
- typecheck?: boolean;
118
- benchmark?: boolean;
119
- failScreenshotPath?: string;
120
- }
121
- interface File {
122
- prepareDuration?: number;
123
- environmentLoad?: number;
124
- }
125
- interface TaskBase {
126
- logs?: UserConsoleLog[];
127
- }
128
- interface TaskResult {
129
- benchmark?: BenchmarkResult;
130
- }
131
- }
132
-
133
- export type { CollectLineNumbers as C, RawErrsMap as R, TscErrorInfo as T, CollectLines as a, RootAndTarget as b, Context as c };