vitest 5.0.0-beta.2 → 5.0.0-beta.3

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 (36) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{base.Opc_YHkk.js → base.Bay6B1Dz.js} +4 -4
  4. package/dist/chunks/{browser.d.BUhkKcDl.d.ts → browser.d.DM1g8UNp.d.ts} +2 -2
  5. package/dist/chunks/{cac.8N4bOkkB.js → cac.DoK9yX-i.js} +8 -6
  6. package/dist/chunks/{cli-api.B0RFke2g.js → cli-api.BCY9ylNq.js} +140 -68
  7. package/dist/chunks/{config.d.D91DHYaD.d.ts → config.d.C0UMwus7.d.ts} +86 -63
  8. package/dist/chunks/{defaults.szbHWQun.js → defaults.DVfzlTkU.js} +1 -1
  9. package/dist/chunks/{env.D4Lgay0q.js → env.BKKtU2WC.js} +2 -1
  10. package/dist/chunks/{global.d.DhbKSQoV.d.ts → global.d.DZbA5YnY.d.ts} +4 -2
  11. package/dist/chunks/{globals.EHmmu0nC.js → globals.8_qjZdeE.js} +1 -1
  12. package/dist/chunks/{index.CViWo__T.js → index.PuMGMNHF.js} +2 -2
  13. package/dist/chunks/{index.D_7-4CaB.js → index.ukHtlBbI.js} +1305 -555
  14. package/dist/chunks/{init-forks.DMge3WTt.js → init-forks.OoZmDo1g.js} +1 -1
  15. package/dist/chunks/{init-threads.eIoyCTon.js → init-threads.eSHAowcx.js} +1 -1
  16. package/dist/chunks/{init.BVd7SaCA.js → init.YjNsCb-_.js} +1 -1
  17. package/dist/chunks/{plugin.d.cIKZEZ16.d.ts → plugin.d.C00LxKL6.d.ts} +35 -9
  18. package/dist/chunks/{setup-common.Hpq30zVk.js → setup-common.eQsbxe88.js} +1 -1
  19. package/dist/chunks/{vm.2okbRRME.js → vm.BE_VOfSs.js} +1 -1
  20. package/dist/chunks/{worker.d.Bu1kXGw4.d.ts → worker.d.Dv3hDCFf.d.ts} +1 -1
  21. package/dist/cli.js +2 -2
  22. package/dist/config.d.ts +6 -7
  23. package/dist/config.js +2 -2
  24. package/dist/index.d.ts +8 -8
  25. package/dist/index.js +1 -1
  26. package/dist/module-evaluator.js +1 -1
  27. package/dist/node.d.ts +7 -8
  28. package/dist/node.js +5 -5
  29. package/dist/worker.d.ts +2 -2
  30. package/dist/worker.js +5 -5
  31. package/dist/workers/forks.js +6 -6
  32. package/dist/workers/runVmTests.js +3 -3
  33. package/dist/workers/threads.js +6 -6
  34. package/dist/workers/vmForks.js +3 -3
  35. package/dist/workers/vmThreads.js +3 -3
  36. package/package.json +19 -20
@@ -4,66 +4,88 @@ import { L as LabelColor, g as SnapshotUpdateState } from './general.d.DFAHgpC2.
4
4
  import { S as SnapshotEnvironment } from './environment.d-DOJxxZV9.d.DOJxxZV9.js';
5
5
  import { SerializedDiffOptions } from '@vitest/utils/diff';
6
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. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
35
- * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
36
- */
37
- toFake?: FakeMethod[] | undefined;
38
-
39
- /**
40
- * The maximum number of timers that will be run when calling runAll() (default: 1000)
41
- */
42
- loopLimit?: number | undefined;
43
-
44
- /**
45
- * 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
46
- * 20ms for every 20ms change in the real system time) (default: false)
47
- */
48
- shouldAdvanceTime?: boolean | undefined;
49
-
50
- /**
51
- * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
52
- * in the real system time (default: 20)
53
- */
54
- advanceTimeDelta?: number | undefined;
55
-
56
- /**
57
- * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
58
- * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
59
- */
60
- shouldClearNativeTimers?: boolean | undefined;
61
-
62
- /**
63
- * Tells FakeTimers to not throw an error when faking a timer that does not exist in the global object. (default: false)
64
- */
65
- ignoreMissingTimers?: boolean | undefined;
66
- }
7
+ type VoidVarArgsFunc = (...args: unknown[]) => void;
8
+ type SetImmediate = (callback: VoidVarArgsFunc, ...args: unknown[]) => NodeImmediate;
9
+ type SetTimeout = (callback: VoidVarArgsFunc, delay?: number, ...args: unknown[]) => TimerId;
10
+ type ClearTimeout = (id?: TimerId) => void;
11
+ type SetInterval = (callback: VoidVarArgsFunc, delay?: number, ...args: unknown[]) => TimerId;
12
+ type ClearInterval = (id?: TimerId) => void;
13
+ type QueueMicrotask = (callback: VoidVarArgsFunc) => void;
14
+ type TimeRemaining = () => number;
15
+ type IdleDeadline = {
16
+ didTimeout: boolean;
17
+ timeRemaining: TimeRemaining;
18
+ };
19
+ type RequestIdleCallbackCallback = (deadline: IdleDeadline) => any;
20
+ type RequestIdleCallback = (callback: RequestIdleCallbackCallback, options?: {
21
+ timeout?: number;
22
+ }) => number;
23
+ type AnimationFrameCallback = (timestamp: number) => any;
24
+ type RequestAnimationFrame = (callback: AnimationFrameCallback) => TimerId;
25
+ type CancelAnimationFrame = (id: TimerId) => void;
26
+ type CancelIdleCallback = (id: TimerId) => void;
27
+ type ClearImmediate = (id: NodeImmediate) => void;
28
+ type FakeMethod = "setTimeout" | "clearTimeout" | "setImmediate" | "clearImmediate" | "setInterval" | "clearInterval" | "Date" | "nextTick" | "hrtime" | "requestAnimationFrame" | "cancelAnimationFrame" | "requestIdleCallback" | "cancelIdleCallback" | "performance" | "queueMicrotask";
29
+ type TimerId = number | NodeImmediate | Timer;
30
+ type GlobalObject = Record<string, any> & {
31
+ setTimeout?: SetTimeout;
32
+ clearTimeout?: ClearTimeout;
33
+ setInterval?: SetInterval;
34
+ clearInterval?: ClearInterval;
35
+ setImmediate?: SetImmediate;
36
+ clearImmediate?: ClearImmediate;
37
+ queueMicrotask?: QueueMicrotask;
38
+ requestAnimationFrame?: RequestAnimationFrame;
39
+ cancelAnimationFrame?: CancelAnimationFrame;
40
+ requestIdleCallback?: RequestIdleCallback;
41
+ cancelIdleCallback?: CancelIdleCallback;
42
+ process?: any;
43
+ performance?: any;
44
+ Performance?: any;
45
+ Intl?: any;
46
+ Promise?: typeof Promise;
47
+ Date: typeof Date & {
48
+ isFake?: boolean;
49
+ toSource?: () => string;
50
+ clock?: any;
51
+ };
52
+ };
53
+ type TimerInitialProps = {
54
+ func: VoidVarArgsFunc;
55
+ args?: unknown[];
56
+ type?: 'Timeout' | 'Interval' | 'Immediate' | 'AnimationFrame' | 'IdleCallback';
57
+ delay?: number;
58
+ callAt?: number;
59
+ createdAt?: number;
60
+ immediate?: boolean;
61
+ id?: number;
62
+ error?: Error;
63
+ interval?: number;
64
+ animation?: boolean;
65
+ requestIdleCallback?: boolean;
66
+ order?: number;
67
+ heapIndex?: number;
68
+ };
69
+ type Config = {
70
+ now?: number | Date;
71
+ toFake?: FakeMethod[];
72
+ toNotFake?: FakeMethod[];
73
+ loopLimit?: number;
74
+ shouldAdvanceTime?: boolean;
75
+ advanceTimeDelta?: number;
76
+ shouldClearNativeTimers?: boolean;
77
+ ignoreMissingTimers?: boolean;
78
+ target?: GlobalObject;
79
+ };
80
+ type Timer = TimerInitialProps;
81
+ type NodeImmediateHasRef = () => boolean;
82
+ type NodeImmediateRef = () => NodeImmediate;
83
+ type NodeImmediateUnref = () => NodeImmediate;
84
+ type NodeImmediate = {
85
+ hasRef: NodeImmediateHasRef;
86
+ ref: NodeImmediateRef;
87
+ unref: NodeImmediateUnref;
88
+ };
67
89
 
68
90
  /**
69
91
  * Config that tests have access to.
@@ -93,7 +115,7 @@ interface SerializedConfig {
93
115
  restoreMocks: boolean;
94
116
  unstubGlobals: boolean;
95
117
  unstubEnvs: boolean;
96
- fakeTimers: FakeTimerInstallOpts;
118
+ fakeTimers: Config;
97
119
  maxConcurrency: number;
98
120
  defines: Record<string, any>;
99
121
  expect: {
@@ -170,6 +192,7 @@ interface SerializedConfig {
170
192
  locators: {
171
193
  testIdAttribute: string;
172
194
  exact: boolean;
195
+ errorFormat: "html" | "aria" | "all";
173
196
  };
174
197
  screenshotFailures: boolean;
175
198
  providerOptions: {
@@ -216,7 +239,7 @@ interface SerializedConfig {
216
239
  strictTags: boolean;
217
240
  mergeReportsLabel: string | undefined;
218
241
  slowTestThreshold: number | undefined;
219
- isAgent: boolean;
242
+ disableColors: boolean;
220
243
  }
221
244
  interface SerializedCoverageConfig {
222
245
  provider: "istanbul" | "v8" | "custom" | undefined;
@@ -237,4 +260,4 @@ type RuntimeConfig = Pick<SerializedConfig, "allowOnly" | "testTimeout" | "hookT
237
260
  type RuntimeOptions = Partial<RuntimeConfig>;
238
261
  type BrowserTraceViewMode = "on" | "off" | "on-first-retry" | "on-all-retries" | "retain-on-failure";
239
262
 
240
- export type { BrowserTraceViewMode as B, FakeTimerInstallOpts as F, RuntimeOptions as R, SerializedRootConfig as S, SerializedConfig as a, RuntimeConfig as b, SerializedCoverageConfig as c };
263
+ export type { BrowserTraceViewMode as B, Config as C, RuntimeOptions as R, SerializedRootConfig as S, SerializedConfig as a, RuntimeConfig as b, SerializedCoverageConfig as c };
@@ -1,5 +1,5 @@
1
1
  import nodeos__default from 'node:os';
2
- import './env.D4Lgay0q.js';
2
+ import './env.BKKtU2WC.js';
3
3
  import { isCI, isAgent } from 'std-env';
4
4
 
5
5
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
@@ -4,5 +4,6 @@ const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.v
4
4
  const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
5
5
  const isWindows = (isNode || isDeno) && process.platform === "win32";
6
6
  const isTTY = (isNode || isDeno) && process.stdout?.isTTY && !isCI;
7
+ const isForceColor = () => "FORCE_COLOR" in process.env;
7
8
 
8
- export { isWindows as a, isTTY as i };
9
+ export { isTTY as a, isWindows as b, isForceColor as i };
@@ -1,4 +1,4 @@
1
- import { P as PromisifyAssertion, T as Tester, E as ExpectStatic, l as BenchmarkResult } from './browser.d.BUhkKcDl.js';
1
+ import { P as PromisifyAssertion, T as Tester, E as ExpectStatic, l as BenchmarkResult } from './browser.d.DM1g8UNp.js';
2
2
  import { Plugin } from '@vitest/pretty-format';
3
3
  import { Test } from '@vitest/runner';
4
4
  import { i as SnapshotState, U as UserConsoleLog } from './general.d.DFAHgpC2.js';
@@ -26,7 +26,9 @@ declare module "vitest" {
26
26
  assert: Chai.AssertStatic;
27
27
  unreachable: (message?: string) => never;
28
28
  soft: <T>(actual: T, message?: string) => Assertion<T>;
29
- poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
29
+ poll: <T>(actual: (options: {
30
+ signal: AbortSignal;
31
+ }) => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
30
32
  addEqualityTesters: (testers: Array<Tester>) => void;
31
33
  assertions: (expected: number) => void;
32
34
  hasAssertions: () => void;
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from './constants.-juJ8b_4.js';
2
- import { i as index } from './index.D_7-4CaB.js';
2
+ import { i as index } from './index.ukHtlBbI.js';
3
3
  import '@vitest/runner';
4
4
  import './utils.BX5Fg8C4.js';
5
5
  import '@vitest/utils/timers';
@@ -1,9 +1,9 @@
1
1
  import * as chai from 'chai';
2
2
  import { createHook } from 'node:async_hooks';
3
- import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.Hpq30zVk.js';
3
+ import { l as loadDiffConfig, a as loadSnapshotSerializers, t as takeCoverageInsideWorker } from './setup-common.eQsbxe88.js';
4
4
  import { r as rpc } from './rpc.DFRWVnRh.js';
5
5
  import { g as getWorkerState } from './utils.BX5Fg8C4.js';
6
- import { T as TestRunner, N as NodeBenchmarkRunner } from './index.D_7-4CaB.js';
6
+ import { T as TestRunner, N as NodeBenchmarkRunner } from './index.ukHtlBbI.js';
7
7
 
8
8
  function setupChaiConfig(config) {
9
9
  Object.assign(chai.config, config);