vitest 0.0.92 → 0.0.96

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.
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import { Formatter } from 'picocolors/types';
2
2
  import { OptionsReceived } from 'pretty-format';
3
3
  import { MessagePort } from 'worker_threads';
4
4
  export { assert, default as chai, expect, should } from 'chai';
5
- export { spy, spyOn } from 'tinyspy';
6
5
 
7
6
  declare const EXPECTED_COLOR: Formatter;
8
7
  declare const RECEIVED_COLOR: Formatter;
@@ -129,6 +128,28 @@ declare class Anything extends AsymmetricMatcher<void> {
129
128
  toString(): string;
130
129
  toAsymmetricMatcher(): string;
131
130
  }
131
+ declare class ObjectContaining extends AsymmetricMatcher<Record<string, unknown>> {
132
+ constructor(sample: Record<string, unknown>, inverse?: boolean);
133
+ getPrototype(obj: object): any;
134
+ hasProperty(obj: object | null, property: string): boolean;
135
+ asymmetricMatch(other: any): boolean;
136
+ toString(): string;
137
+ getExpectedType(): string;
138
+ }
139
+ declare class ArrayContaining extends AsymmetricMatcher<Array<unknown>> {
140
+ constructor(sample: Array<unknown>, inverse?: boolean);
141
+ asymmetricMatch(other: Array<unknown>): boolean;
142
+ toString(): string;
143
+ getExpectedType(): string;
144
+ }
145
+ declare class Any extends AsymmetricMatcher<any> {
146
+ constructor(sample: unknown);
147
+ fnNameFor(func: Function): string;
148
+ asymmetricMatch(other: unknown): boolean;
149
+ toString(): string;
150
+ getExpectedType(): string;
151
+ toAsymmetricMatcher(): string;
152
+ }
132
153
 
133
154
  declare type Awaitable<T> = T | PromiseLike<T>;
134
155
  declare type Nullable<T> = T | null | undefined;
@@ -609,21 +630,25 @@ declare function fn<TArgs extends any[] = any[], R = any>(): JestMockCompatFn<TA
609
630
  declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): JestMockCompatFn<TArgs, R>;
610
631
 
611
632
  declare class VitestUtils {
612
- spyOn: typeof spyOn;
613
- fn: typeof fn;
614
- mock: (path: string) => string;
615
633
  private _timers;
616
634
  constructor();
617
635
  useFakeTimers(): void;
618
636
  useRealTimers(): void;
619
- runOnlyPendingTimers(): void;
620
- runAllTimers(): void;
621
- advanceTimersByTime(ms: number): void;
622
- advanceTimersToNextTimer(): void;
623
- runAllTicks(): void;
637
+ runOnlyPendingTimers(): void | Promise<void>;
638
+ runAllTimers(): void | Promise<void>;
639
+ advanceTimersByTime(ms: number): void | Promise<void>;
640
+ advanceTimersToNextTimer(): void | Promise<void>;
641
+ runAllTicks(): void | Promise<void>;
624
642
  setSystemTime(time?: number | Date): void;
625
643
  getRealSystemTime(): number;
626
644
  getTimerCount(): number;
645
+ spyOn: typeof spyOn;
646
+ fn: typeof fn;
647
+ mock: (path: string) => string;
648
+ isMockFunction(fn: any): any;
649
+ clearAllMocks(): void;
650
+ resetAllMocks(): void;
651
+ restoreAllMocks(): void;
627
652
  }
628
653
  declare const vitest: VitestUtils;
629
654
  declare const vi: VitestUtils;
@@ -642,6 +667,9 @@ declare global {
642
667
  extend(expects: MatchersObject): void;
643
668
  stringContaining(expected: string): void;
644
669
  anything(): Anything;
670
+ objectContaining(expected: any): ObjectContaining;
671
+ any(constructor: unknown): Any;
672
+ arrayContaining(expected: any): ArrayContaining;
645
673
  }
646
674
  interface Assertion {
647
675
  chaiEqual(expected: any): void;
@@ -696,4 +724,4 @@ declare global {
696
724
  }
697
725
  }
698
726
 
699
- export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vi, vitest };
727
+ export { ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, ComputeMode, DoneCallback, Environment, EnvironmentReturn, File, HookListener, InlineConfig, JestMockCompat, JestMockCompatContext, JestMockCompatFn, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConfig, UserConsoleLog, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, fn, it, spyOn, suite, test, vi, vitest };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { d as describe, i as it, s as suite, t as test } from './suite-b8c6cb53.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as vi, v as vitest } from './index-708135df.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, f as fn, s as spyOn, e as vi, v as vitest } from './index-368448f4.js';
3
3
  export { assert, default as chai, expect, should } from 'chai';
4
- export { spy, spyOn } from 'tinyspy';
5
4
  import './index-9e71c815.js';
5
+ import 'tinyspy';
@@ -54,13 +54,12 @@ function sendFlatted(res, data) {
54
54
  res.statusCode = 200;
55
55
  res.end();
56
56
  }
57
- function middlewareAPI() {
57
+ function middlewareAPI(ctx) {
58
58
  return (req, res, next) => {
59
59
  var _a;
60
60
  if (!((_a = req.url) == null ? void 0 : _a.startsWith(API_PATH)))
61
61
  return next();
62
62
  const url = req.url.slice(API_PATH.length);
63
- const ctx = process.__vitest__;
64
63
  if (url === "/") {
65
64
  return sendFlatted(res, {
66
65
  files: ctx.state.filesMap
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- export { c as createVitest } from './index-40ecbcb4.js';
1
+ export { c as createVitest } from './index-ece64e3c.js';
2
2
  import 'path';
3
3
  import 'vite';
4
4
  import 'process';
@@ -7,14 +7,14 @@ import 'fast-glob';
7
7
  import 'util';
8
8
  import './constants-9cfa4d7b.js';
9
9
  import 'url';
10
- import './utils-860e5f7e.js';
10
+ import './utils-576876dc.js';
11
11
  import 'tty';
12
12
  import 'local-pkg';
13
13
  import 'perf_hooks';
14
- import './error-4b0c4b4b.js';
14
+ import './error-81292c96.js';
15
15
  import 'source-map';
16
16
  import './index-5cc247ff.js';
17
17
  import 'assert';
18
18
  import 'events';
19
19
  import 'worker_threads';
20
- import 'piscina';
20
+ import 'tinypool';
@@ -76,6 +76,8 @@ function notNullish(v) {
76
76
  function slash(str) {
77
77
  return str.replace(/\\/g, "/");
78
78
  }
79
+ const noop = () => {
80
+ };
79
81
  function partitionSuiteChildren(suite) {
80
82
  let tasksGroup = [];
81
83
  const tasksGroups = [];
@@ -148,7 +150,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
148
150
  const { install } = await prompts.prompt({
149
151
  type: "confirm",
150
152
  name: "install",
151
- message: `Do you want to install ${c.green(dependency)}?`
153
+ message: c.reset(`Do you want to install ${c.green(dependency)}?`)
152
154
  });
153
155
  if (install) {
154
156
  await (await import('./index-e7a421bb.js')).installPackage(dependency);
@@ -157,4 +159,4 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
157
159
  return false;
158
160
  }
159
161
 
160
- export { getTests as a, getSuites as b, c, hasTests as d, ensurePackageInstalled as e, getTasks as f, getNames as g, hasFailed as h, interpretOnlyMode as i, notNullish as n, partitionSuiteChildren as p, slash as s, toArray as t };
162
+ export { getTests as a, getSuites as b, c, notNullish as d, ensurePackageInstalled as e, hasTests as f, getNames as g, hasFailed as h, interpretOnlyMode as i, getTasks as j, noop as n, partitionSuiteChildren as p, slash as s, toArray as t };
package/dist/utils.js CHANGED
@@ -1,3 +1,3 @@
1
- export { e as ensurePackageInstalled, g as getNames, b as getSuites, f as getTasks, a as getTests, h as hasFailed, d as hasTests, i as interpretOnlyMode, n as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-860e5f7e.js';
1
+ export { e as ensurePackageInstalled, g as getNames, b as getSuites, j as getTasks, a as getTests, h as hasFailed, f as hasTests, i as interpretOnlyMode, n as noop, d as notNullish, p as partitionSuiteChildren, s as slash, t as toArray } from './utils-576876dc.js';
2
2
  import 'local-pkg';
3
3
  import 'tty';