vitest 0.24.5 → 0.25.1

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 (49) hide show
  1. package/LICENSE.md +286 -57
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +18 -11
  4. package/dist/{chunk-api-setup.629f8133.js → chunk-api-setup.f40616e2.js} +38 -19
  5. package/dist/{chunk-env-node.700b7e95.js → chunk-env-node.67948209.js} +8 -11
  6. package/dist/{chunk-install-pkg.22707ee4.js → chunk-install-pkg.579a5a27.js} +3 -4
  7. package/dist/{chunk-integrations-coverage.cca09977.js → chunk-integrations-coverage.befed097.js} +57 -1
  8. package/dist/chunk-integrations-globals.796fe181.js +25 -0
  9. package/dist/{chunk-node-git.82174cfe.js → chunk-node-git.5a1b1656.js} +5 -6
  10. package/dist/{chunk-runtime-chain.37ec5d73.js → chunk-runtime-chain.e387e274.js} +36 -25
  11. package/dist/{chunk-runtime-error.17751c39.js → chunk-runtime-error.6287172c.js} +9 -2
  12. package/dist/{chunk-runtime-mocker.41b92ec9.js → chunk-runtime-mocker.503a4f67.js} +4 -4
  13. package/dist/{chunk-runtime-rpc.b418c0ab.js → chunk-runtime-rpc.1e7530d3.js} +2 -2
  14. package/dist/chunk-runtime-setup.5c4e0f49.js +1363 -0
  15. package/dist/{chunk-runtime-hooks.d748b085.js → chunk-runtime-test-state.4ed42543.js} +119 -6
  16. package/dist/{chunk-mock-date.030959d3.js → chunk-typecheck-constants.4891f22f.js} +23 -4
  17. package/dist/{chunk-utils-env.b1281522.js → chunk-utils-env.03f840f2.js} +2 -0
  18. package/dist/chunk-utils-source-map.c6dfbbc1.js +90 -0
  19. package/dist/{chunk-utils-timers.8fca243e.js → chunk-utils-timers.06f993db.js} +86 -79
  20. package/dist/{chunk-vite-node-client.3868b3ba.js → chunk-vite-node-client.b2ab6dcf.js} +25 -5
  21. package/dist/{chunk-vite-node-externalize.d9033432.js → chunk-vite-node-externalize.477f36a4.js} +821 -92
  22. package/dist/chunk-vite-node-utils.8f0b4a12.js +1400 -0
  23. package/dist/cli-wrapper.js +5 -6
  24. package/dist/cli.js +27 -13
  25. package/dist/config.cjs +6 -1
  26. package/dist/config.d.ts +6 -1
  27. package/dist/config.js +6 -1
  28. package/dist/entry.js +15 -13
  29. package/dist/environments.d.ts +1 -1
  30. package/dist/environments.js +1 -1
  31. package/dist/index-2f5b6168.d.ts +256 -0
  32. package/dist/index.d.ts +13 -4
  33. package/dist/index.js +13 -7
  34. package/dist/loader.js +4 -3
  35. package/dist/node.d.ts +2 -2
  36. package/dist/node.js +18 -11
  37. package/dist/suite.js +6 -6
  38. package/dist/{global-58e8e951.d.ts → types-f302dae9.d.ts} +210 -19
  39. package/dist/{vendor-index.cc8d244b.js → vendor-index.737c3cff.js} +1 -2
  40. package/dist/{vendor-index.12d51d29.js → vendor-index.e1d4cf84.js} +279 -7
  41. package/dist/worker.js +9 -8
  42. package/globals.d.ts +2 -0
  43. package/package.json +13 -9
  44. package/dist/chunk-integrations-globals.32ef80c3.js +0 -25
  45. package/dist/chunk-runtime-setup.ab6b6274.js +0 -676
  46. package/dist/chunk-utils-source-map.663e2952.js +0 -3429
  47. package/dist/chunk-vite-node-utils.2144000e.js +0 -6946
  48. package/dist/index-220c1d70.d.ts +0 -117
  49. package/dist/vendor-index.1a291e86.js +0 -275
@@ -1,20 +1,19 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { p as picocolors, E as EXIT_CODE_RESTART } from './chunk-utils-env.b1281522.js';
3
- import { e as execa } from './vendor-index.cc8d244b.js';
2
+ import { p as picocolors, E as EXIT_CODE_RESTART } from './chunk-utils-env.03f840f2.js';
3
+ import { e as execa } from './vendor-index.737c3cff.js';
4
4
  import 'tty';
5
5
  import 'path';
6
6
  import 'buffer';
7
7
  import 'child_process';
8
8
  import 'process';
9
- import './vendor-index.12d51d29.js';
9
+ import './vendor-index.e1d4cf84.js';
10
10
  import './vendor-_commonjsHelpers.addc3445.js';
11
11
  import 'fs';
12
+ import 'assert';
13
+ import 'events';
12
14
  import 'stream';
13
15
  import 'util';
14
16
  import 'os';
15
- import './vendor-index.1a291e86.js';
16
- import 'assert';
17
- import 'events';
18
17
 
19
18
  const ENTRY = new URL("./cli.js", import.meta.url);
20
19
  const NODE_ARGS = [
package/dist/cli.js CHANGED
@@ -1,14 +1,14 @@
1
- import { p as picocolors, n as normalize } from './chunk-utils-env.b1281522.js';
1
+ import { p as picocolors, n as normalize } from './chunk-utils-env.03f840f2.js';
2
2
  import { EventEmitter } from 'events';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.d9033432.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.477f36a4.js';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
7
- import './chunk-integrations-coverage.cca09977.js';
7
+ import './chunk-integrations-coverage.befed097.js';
8
8
  import 'local-pkg';
9
- import './chunk-env-node.700b7e95.js';
9
+ import './chunk-env-node.67948209.js';
10
10
  import 'console';
11
- import './chunk-mock-date.030959d3.js';
11
+ import './chunk-typecheck-constants.4891f22f.js';
12
12
  import 'vite';
13
13
  import 'process';
14
14
  import 'fs';
@@ -16,20 +16,27 @@ import 'os';
16
16
  import 'util';
17
17
  import 'stream';
18
18
  import './vendor-_commonjsHelpers.addc3445.js';
19
- import './chunk-vite-node-client.3868b3ba.js';
19
+ import './chunk-vite-node-client.b2ab6dcf.js';
20
20
  import 'module';
21
21
  import 'vm';
22
- import './chunk-vite-node-utils.2144000e.js';
22
+ import './chunk-vite-node-utils.8f0b4a12.js';
23
+ import 'acorn';
23
24
  import 'assert';
24
25
  import 'debug';
25
26
  import 'perf_hooks';
27
+ import 'fs/promises';
28
+ import './vendor-index.737c3cff.js';
29
+ import 'buffer';
30
+ import 'child_process';
31
+ import './vendor-index.e1d4cf84.js';
32
+ import 'source-map';
33
+ import 'acorn-walk';
26
34
  import 'worker_threads';
27
35
  import 'tinypool';
28
- import './chunk-utils-timers.8fca243e.js';
29
- import './chunk-utils-source-map.663e2952.js';
36
+ import './chunk-utils-timers.06f993db.js';
37
+ import './chunk-utils-source-map.c6dfbbc1.js';
30
38
  import 'crypto';
31
39
  import './vendor-index.9c919048.js';
32
- import './vendor-index.1a291e86.js';
33
40
  import './chunk-magic-string.ffe2b171.js';
34
41
  import 'strip-literal';
35
42
  import 'readline';
@@ -655,6 +662,7 @@ cli.command("related [...filters]").action(runRelated);
655
662
  cli.command("watch [...filters]").action(watch);
656
663
  cli.command("dev [...filters]").action(watch);
657
664
  cli.command("bench [...filters]").action(benchmark);
665
+ cli.command("typecheck [...filters]").action(typecheck);
658
666
  cli.command("[...filters]").action((filters, options) => start("test", filters, options));
659
667
  cli.parse();
660
668
  async function runRelated(relatedFiles, argv) {
@@ -674,6 +682,10 @@ async function benchmark(cliFilters, options) {
674
682
  console.warn(picocolors.exports.yellow("Benchmarking is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
675
683
  await start("benchmark", cliFilters, options);
676
684
  }
685
+ async function typecheck(cliFilters = [], options = {}) {
686
+ console.warn(picocolors.exports.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
687
+ await start("typecheck", cliFilters, options);
688
+ }
677
689
  function normalizeOptions(argv) {
678
690
  argv.root = argv.root && normalize(argv.root);
679
691
  argv.config = argv.config && normalize(argv.config);
@@ -682,13 +694,15 @@ function normalizeOptions(argv) {
682
694
  }
683
695
  async function start(mode, cliFilters, options) {
684
696
  try {
685
- if (await startVitest(mode, cliFilters.map(normalize), normalizeOptions(options)) === false)
686
- process.exit();
697
+ const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeOptions(options));
698
+ if (!(ctx == null ? void 0 : ctx.config.watch))
699
+ await (ctx == null ? void 0 : ctx.exit());
700
+ return ctx;
687
701
  } catch (e) {
688
- process.exitCode = 1;
689
702
  console.error(`
690
703
  ${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Error "))))}`);
691
704
  console.error(e);
692
705
  console.error("\n\n");
706
+ process.exit(1);
693
707
  }
694
708
  }
package/dist/config.cjs CHANGED
@@ -76,7 +76,12 @@ const config = {
76
76
  coverage: coverageConfigDefaults,
77
77
  fakeTimers: fakeTimersDefaults,
78
78
  maxConcurrency: 5,
79
- dangerouslyIgnoreUnhandledErrors: false
79
+ dangerouslyIgnoreUnhandledErrors: false,
80
+ typecheck: {
81
+ checker: "tsc",
82
+ include: ["**/*.{test,spec}-d.{ts,js}"],
83
+ exclude: defaultExclude
84
+ }
80
85
  };
81
86
  const configDefaults = Object.freeze(config);
82
87
 
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, ad as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './global-58e8e951.js';
3
+ import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-f302dae9.js';
4
4
  import 'tinybench';
5
5
  import 'fs';
6
6
  import 'worker_threads';
@@ -38,6 +38,11 @@ declare const config: {
38
38
  fakeTimers: FakeTimerInstallOpts;
39
39
  maxConcurrency: number;
40
40
  dangerouslyIgnoreUnhandledErrors: boolean;
41
+ typecheck: {
42
+ checker: "tsc";
43
+ include: string[];
44
+ exclude: string[];
45
+ };
41
46
  };
42
47
  declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
43
48
 
package/dist/config.js CHANGED
@@ -72,7 +72,12 @@ const config = {
72
72
  coverage: coverageConfigDefaults,
73
73
  fakeTimers: fakeTimersDefaults,
74
74
  maxConcurrency: 5,
75
- dangerouslyIgnoreUnhandledErrors: false
75
+ dangerouslyIgnoreUnhandledErrors: false,
76
+ typecheck: {
77
+ checker: "tsc",
78
+ include: ["**/*.{test,spec}-d.{ts,js}"],
79
+ exclude: defaultExclude
80
+ }
76
81
  };
77
82
  const configDefaults = Object.freeze(config);
78
83
 
package/dist/entry.js CHANGED
@@ -1,26 +1,27 @@
1
1
  import { promises } from 'fs';
2
- import { g as getWorkerState, a as resetModules } from './chunk-mock-date.030959d3.js';
3
- import { a as envs } from './chunk-env-node.700b7e95.js';
4
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.ab6b6274.js';
2
+ import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.4891f22f.js';
3
+ import { v as vi } from './chunk-runtime-test-state.4ed42543.js';
4
+ import { a as envs } from './chunk-env-node.67948209.js';
5
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.5c4e0f49.js';
5
6
  import 'path';
6
- import './chunk-utils-env.b1281522.js';
7
+ import './chunk-utils-env.03f840f2.js';
7
8
  import 'tty';
8
9
  import 'url';
9
10
  import 'local-pkg';
10
- import 'console';
11
- import 'perf_hooks';
12
- import './chunk-integrations-coverage.cca09977.js';
13
- import './chunk-runtime-hooks.d748b085.js';
14
- import './chunk-runtime-chain.37ec5d73.js';
11
+ import './chunk-runtime-chain.e387e274.js';
15
12
  import 'util';
16
13
  import 'chai';
17
14
  import './vendor-_commonjsHelpers.addc3445.js';
18
- import './chunk-runtime-rpc.b418c0ab.js';
19
- import './chunk-utils-timers.8fca243e.js';
20
- import './chunk-utils-source-map.663e2952.js';
15
+ import './chunk-runtime-rpc.1e7530d3.js';
16
+ import './chunk-utils-timers.06f993db.js';
17
+ import './chunk-utils-source-map.c6dfbbc1.js';
21
18
  import './spy.js';
22
19
  import 'tinyspy';
23
- import './chunk-runtime-error.17751c39.js';
20
+ import 'console';
21
+ import 'perf_hooks';
22
+ import './chunk-integrations-coverage.befed097.js';
23
+ import './chunk-runtime-error.6287172c.js';
24
+ import 'source-map';
24
25
 
25
26
  function groupBy(collection, iteratee) {
26
27
  return collection.reduce((acc, item) => {
@@ -72,6 +73,7 @@ async function run(files, config) {
72
73
  workerState.filepath = file;
73
74
  await startTests([file], config);
74
75
  workerState.filepath = void 0;
76
+ vi.resetConfig();
75
77
  }
76
78
  });
77
79
  }
@@ -1,4 +1,4 @@
1
- import { a3 as Environment } from './global-58e8e951.js';
1
+ import { ae as Environment } from './types-f302dae9.js';
2
2
  import 'vite';
3
3
  import 'tinybench';
4
4
  import 'fs';
@@ -1,3 +1,3 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './chunk-env-node.700b7e95.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunk-env-node.67948209.js';
2
2
  import 'console';
3
3
  import 'local-pkg';
@@ -0,0 +1,256 @@
1
+ import { SpyImpl } from 'tinyspy';
2
+ import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-f302dae9.js';
3
+
4
+ declare type Not<T extends boolean> = T extends true ? false : true;
5
+ declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
6
+ declare type Eq<Left extends boolean, Right extends boolean> = Left extends true ? Right : Not<Right>;
7
+ declare const secret: unique symbol;
8
+ declare type Secret = typeof secret;
9
+ declare type IsNever<T> = [T] extends [never] ? true : false;
10
+ declare type IsAny<T> = [T] extends [Secret] ? Not<IsNever<T>> : false;
11
+ declare type IsUnknown<T> = [unknown] extends [T] ? Not<IsAny<T>> : false;
12
+ /**
13
+ * Recursively walk a type and replace it with a branded type related to the original. This is useful for
14
+ * equality-checking stricter than `A extends B ? B extends A ? true : false : false`, because it detects
15
+ * the difference between a few edge-case types that vanilla typescript doesn't by default:
16
+ * - `any` vs `unknown`
17
+ * - `{ readonly a: string }` vs `{ a: string }`
18
+ * - `{ a?: string }` vs `{ a: string | undefined }`
19
+ */
20
+ declare type DeepBrand<T> = IsNever<T> extends true ? {
21
+ type: 'never';
22
+ } : IsAny<T> extends true ? {
23
+ type: 'any';
24
+ } : IsUnknown<T> extends true ? {
25
+ type: 'unknown';
26
+ } : T extends string | number | boolean | symbol | bigint | null | undefined | void ? {
27
+ type: 'primitive';
28
+ value: T;
29
+ } : T extends new (...args: any[]) => any ? {
30
+ type: 'constructor';
31
+ params: ConstructorParams<T>;
32
+ instance: DeepBrand<InstanceType<Extract<T, new (...args: any) => any>>>;
33
+ } : T extends (...args: infer P) => infer R ? {
34
+ type: 'function';
35
+ params: DeepBrand<P>;
36
+ return: DeepBrand<R>;
37
+ } : T extends any[] ? {
38
+ type: 'array';
39
+ items: {
40
+ [K in keyof T]: T[K];
41
+ };
42
+ } : {
43
+ type: 'object';
44
+ properties: {
45
+ [K in keyof T]: DeepBrand<T[K]>;
46
+ };
47
+ readonly: ReadonlyKeys<T>;
48
+ required: RequiredKeys<T>;
49
+ optional: OptionalKeys<T>;
50
+ constructorParams: DeepBrand<ConstructorParams<T>>;
51
+ };
52
+ declare type RequiredKeys<T> = Extract<{
53
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
54
+ }[keyof T], keyof T>;
55
+ declare type OptionalKeys<T> = Exclude<keyof T, RequiredKeys<T>>;
56
+ declare type ReadonlyKeys<T> = Extract<{
57
+ [K in keyof T]-?: ReadonlyEquivalent<{
58
+ [_K in K]: T[K];
59
+ }, {
60
+ -readonly [_K in K]: T[K];
61
+ }> extends true ? never : K;
62
+ }[keyof T], keyof T>;
63
+ declare type ReadonlyEquivalent<X, Y> = Extends<(<T>() => T extends X ? true : false), (<T>() => T extends Y ? true : false)>;
64
+ declare type Extends<L, R> = IsNever<L> extends true ? IsNever<R> : [L] extends [R] ? true : false;
65
+ declare type StrictExtends<L, R> = Extends<DeepBrand<L>, DeepBrand<R>>;
66
+ declare type Equal<Left, Right> = And<[StrictExtends<Left, Right>, StrictExtends<Right, Left>]>;
67
+ declare type Params<Actual> = Actual extends (...args: infer P) => any ? P : never;
68
+ declare type ConstructorParams<Actual> = Actual extends new (...args: infer P) => any ? Actual extends new () => any ? P | [] : P : never;
69
+ declare type MismatchArgs<B extends boolean, C extends boolean> = Eq<B, C> extends true ? [] : [never];
70
+ interface ExpectTypeOf<Actual, B extends boolean> {
71
+ toBeAny: (...MISMATCH: MismatchArgs<IsAny<Actual>, B>) => true;
72
+ toBeUnknown: (...MISMATCH: MismatchArgs<IsUnknown<Actual>, B>) => true;
73
+ toBeNever: (...MISMATCH: MismatchArgs<IsNever<Actual>, B>) => true;
74
+ toBeFunction: (...MISMATCH: MismatchArgs<Extends<Actual, (...args: any[]) => any>, B>) => true;
75
+ toBeObject: (...MISMATCH: MismatchArgs<Extends<Actual, object>, B>) => true;
76
+ toBeArray: (...MISMATCH: MismatchArgs<Extends<Actual, any[]>, B>) => true;
77
+ toBeNumber: (...MISMATCH: MismatchArgs<Extends<Actual, number>, B>) => true;
78
+ toBeString: (...MISMATCH: MismatchArgs<Extends<Actual, string>, B>) => true;
79
+ toBeBoolean: (...MISMATCH: MismatchArgs<Extends<Actual, boolean>, B>) => true;
80
+ toBeVoid: (...MISMATCH: MismatchArgs<Extends<Actual, void>, B>) => true;
81
+ toBeSymbol: (...MISMATCH: MismatchArgs<Extends<Actual, symbol>, B>) => true;
82
+ toBeNull: (...MISMATCH: MismatchArgs<Extends<Actual, null>, B>) => true;
83
+ toBeUndefined: (...MISMATCH: MismatchArgs<Extends<Actual, undefined>, B>) => true;
84
+ toBeNullable: (...MISMATCH: MismatchArgs<Not<Equal<Actual, NonNullable<Actual>>>, B>) => true;
85
+ toMatchTypeOf: {
86
+ <Expected>(...MISMATCH: MismatchArgs<Extends<Actual, Expected>, B>): true;
87
+ <Expected>(expected: Expected, ...MISMATCH: MismatchArgs<Extends<Actual, Expected>, B>): true;
88
+ };
89
+ toEqualTypeOf: {
90
+ <Expected>(...MISMATCH: MismatchArgs<Equal<Actual, Expected>, B>): true;
91
+ <Expected>(expected: Expected, ...MISMATCH: MismatchArgs<Equal<Actual, Expected>, B>): true;
92
+ };
93
+ toBeCallableWith: B extends true ? (...args: Params<Actual>) => true : never;
94
+ toBeConstructibleWith: B extends true ? (...args: ConstructorParams<Actual>) => true : never;
95
+ toHaveProperty: <K extends string>(key: K, ...MISMATCH: MismatchArgs<Extends<K, keyof Actual>, B>) => K extends keyof Actual ? ExpectTypeOf<Actual[K], B> : true;
96
+ extract: <V>(v?: V) => ExpectTypeOf<Extract<Actual, V>, B>;
97
+ exclude: <V>(v?: V) => ExpectTypeOf<Exclude<Actual, V>, B>;
98
+ parameter: <K extends keyof Params<Actual>>(number: K) => ExpectTypeOf<Params<Actual>[K], B>;
99
+ parameters: ExpectTypeOf<Params<Actual>, B>;
100
+ constructorParameters: ExpectTypeOf<ConstructorParams<Actual>, B>;
101
+ instance: Actual extends new (...args: any[]) => infer I ? ExpectTypeOf<I, B> : never;
102
+ returns: Actual extends (...args: any[]) => infer R ? ExpectTypeOf<R, B> : never;
103
+ resolves: Actual extends PromiseLike<infer R> ? ExpectTypeOf<R, B> : never;
104
+ items: Actual extends ArrayLike<infer R> ? ExpectTypeOf<R, B> : never;
105
+ guards: Actual extends (v: any, ...args: any[]) => v is infer T ? ExpectTypeOf<T, B> : never;
106
+ asserts: Actual extends (v: any, ...args: any[]) => asserts v is infer T ? unknown extends T ? never : ExpectTypeOf<T, B> : never;
107
+ not: ExpectTypeOf<Actual, Not<B>>;
108
+ }
109
+ declare type _ExpectTypeOf = {
110
+ <Actual>(actual: Actual): ExpectTypeOf<Actual, true>;
111
+ <Actual>(): ExpectTypeOf<Actual, true>;
112
+ };
113
+ /**
114
+ * Similar to Jest's `expect`, but with type-awareness.
115
+ * Gives you access to a number of type-matchers that let you make assertions about the
116
+ * form of a reference or generic type parameter.
117
+ *
118
+ * @example
119
+ * import {foo, bar} from '../foo'
120
+ * import {expectTypeOf} from 'expect-type'
121
+ *
122
+ * test('foo types', () => {
123
+ * // make sure `foo` has type {a: number}
124
+ * expectTypeOf(foo).toMatchTypeOf({a: 1})
125
+ * expectTypeOf(foo).toHaveProperty('a').toBeNumber()
126
+ *
127
+ * // make sure `bar` is a function taking a string:
128
+ * expectTypeOf(bar).parameter(0).toBeString()
129
+ * expectTypeOf(bar).returns.not.toBeAny()
130
+ * })
131
+ *
132
+ * @description
133
+ * See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.
134
+ */
135
+ declare const expectTypeOf: _ExpectTypeOf;
136
+
137
+ interface AssertType {
138
+ <T>(value: T): void;
139
+ }
140
+ declare const assertType: AssertType;
141
+
142
+ interface MockResultReturn<T> {
143
+ type: 'return';
144
+ value: T;
145
+ }
146
+ interface MockResultIncomplete {
147
+ type: 'incomplete';
148
+ value: undefined;
149
+ }
150
+ interface MockResultThrow {
151
+ type: 'throw';
152
+ value: any;
153
+ }
154
+ declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
155
+ interface MockContext<TArgs, TReturns> {
156
+ calls: TArgs[];
157
+ instances: TReturns[];
158
+ invocationCallOrder: number[];
159
+ results: MockResult<TReturns>[];
160
+ lastCall: TArgs | undefined;
161
+ }
162
+ declare type Procedure = (...args: any[]) => any;
163
+ declare type Methods<T> = {
164
+ [K in keyof T]: T[K] extends Procedure ? K : never;
165
+ }[keyof T] & (string | symbol);
166
+ declare type Properties<T> = {
167
+ [K in keyof T]: T[K] extends Procedure ? never : K;
168
+ }[keyof T] & (string | symbol);
169
+ declare type Classes<T> = {
170
+ [K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
171
+ }[keyof T] & (string | symbol);
172
+ interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
173
+ getMockName(): string;
174
+ mockName(n: string): this;
175
+ mock: MockContext<TArgs, TReturns>;
176
+ mockClear(): this;
177
+ mockReset(): this;
178
+ mockRestore(): void;
179
+ getMockImplementation(): ((...args: TArgs) => TReturns) | undefined;
180
+ mockImplementation(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
181
+ mockImplementationOnce(fn: ((...args: TArgs) => TReturns) | (() => Promise<TReturns>)): this;
182
+ mockReturnThis(): this;
183
+ mockReturnValue(obj: TReturns): this;
184
+ mockReturnValueOnce(obj: TReturns): this;
185
+ mockResolvedValue(obj: Awaited<TReturns>): this;
186
+ mockResolvedValueOnce(obj: Awaited<TReturns>): this;
187
+ mockRejectedValue(obj: any): this;
188
+ mockRejectedValueOnce(obj: any): this;
189
+ }
190
+ interface MockInstance<A extends any[] = any[], R = any> extends SpyInstance<A, R> {
191
+ }
192
+ interface Mock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
193
+ new (...args: TArgs): TReturns;
194
+ (...args: TArgs): TReturns;
195
+ }
196
+ interface PartialMock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, Partial<TReturns>> {
197
+ new (...args: TArgs): TReturns;
198
+ (...args: TArgs): TReturns;
199
+ }
200
+ declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<ConstructorParameters<T>, R> : T;
201
+ declare type MockedFunction<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & {
202
+ [K in keyof T]: T[K];
203
+ };
204
+ declare type PartiallyMockedFunction<T extends Procedure> = PartialMock<Parameters<T>, ReturnType<T>> & {
205
+ [K in keyof T]: T[K];
206
+ };
207
+ declare type MockedFunctionDeep<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
208
+ declare type PartiallyMockedFunctionDeep<T extends Procedure> = PartialMock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
209
+ declare type MockedObject<T> = MaybeMockedConstructor<T> & {
210
+ [K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
211
+ } & {
212
+ [K in Properties<T>]: T[K];
213
+ };
214
+ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
215
+ [K in Methods<T>]: T[K] extends Procedure ? MockedFunctionDeep<T[K]> : T[K];
216
+ } & {
217
+ [K in Properties<T>]: MaybeMockedDeep<T[K]>;
218
+ };
219
+ declare type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
220
+ declare type MaybePartiallyMockedDeep<T> = T extends Procedure ? PartiallyMockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
221
+ declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
222
+ declare type MaybePartiallyMocked<T> = T extends Procedure ? PartiallyMockedFunction<T> : T extends object ? MockedObject<T> : T;
223
+ interface Constructable {
224
+ new (...args: any[]): any;
225
+ }
226
+ declare type MockedClass<T extends Constructable> = MockInstance<T extends new (...args: infer P) => any ? P : never, InstanceType<T>> & {
227
+ prototype: T extends {
228
+ prototype: any;
229
+ } ? Mocked<T['prototype']> : never;
230
+ } & T;
231
+ declare type Mocked<T> = {
232
+ [P in keyof T]: T[P] extends (...args: infer Args) => infer Returns ? MockInstance<Args, Returns> : T[P] extends Constructable ? MockedClass<T[P]> : T[P];
233
+ } & T;
234
+ declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
235
+ declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
236
+ declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
237
+ declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends (...args: infer A) => infer R | (new (...args: infer A) => infer R) ? SpyInstance<A, R> : never;
238
+ declare function fn<TArgs extends any[] = any[], R = any>(): Mock<TArgs, R>;
239
+ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<TArgs, R>;
240
+
241
+ declare const suite: SuiteAPI<{}>;
242
+ declare const test: TestAPI<{}>;
243
+ declare const bench: BenchmarkAPI;
244
+ declare const describe: SuiteAPI<{}>;
245
+ declare const it: TestAPI<{}>;
246
+
247
+ declare const beforeAll: (fn: SuiteHooks['beforeAll'][0], timeout?: number) => void;
248
+ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number) => void;
249
+ declare const beforeEach: <ExtraContext = {}>(fn: HookListener<[TestContext & ExtraContext, Suite], HookCleanupCallback>, timeout?: number) => void;
250
+ declare const afterEach: <ExtraContext = {}>(fn: HookListener<[TestContext & ExtraContext, Suite], void>, timeout?: number) => void;
251
+ declare const onTestFailed: (fn: OnTestFailedHandler) => void;
252
+
253
+ declare function createExpect(test?: Test): Vi.ExpectStatic;
254
+ declare const globalExpect: Vi.ExpectStatic;
255
+
256
+ export { AssertType as A, MockedClass as B, EnhancedSpy as E, MaybeMockedDeep as M, SpyInstance as S, MaybeMocked as a, MaybePartiallyMocked as b, MaybePartiallyMockedDeep as c, suite as d, describe as e, fn as f, bench as g, beforeAll as h, it as i, afterAll as j, beforeEach as k, afterEach as l, globalExpect as m, createExpect as n, onTestFailed as o, expectTypeOf as p, ExpectTypeOf as q, assertType as r, spyOn as s, test as t, MockedFunction as u, MockedObject as v, MockInstance as w, Mock as x, MockContext as y, Mocked as z };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-220c1d70.js';
2
- export { E as EnhancedSpy, r as Mock, u as MockContext, q as MockInstance, v as Mocked, w as MockedClass, o as MockedFunction, p as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, i as it, d as suite, t as test } from './index-220c1d70.js';
3
- import { D as DoneCallback, F as FakeTimerInstallOpts, a as File, T as TaskResultPack, R as ResolvedConfig, M as ModuleGraphData, b as Reporter } from './global-58e8e951.js';
4
- export { L as AfterSuiteRunMeta, A as ApiConfig, Y as ArgumentsType, X as Arrayable, P as Awaitable, ae as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, B as BuiltinEnvironment, C as CSSModuleScopeStrategy, a0 as Constructable, ag as CoverageC8Options, af as CoverageIstanbulOptions, ac as CoverageOptions, a9 as CoverageProvider, aa as CoverageProviderModule, ab as CoverageReporter, _ as DeepMerge, D as DoneCallback, a3 as Environment, E as EnvironmentOptions, a2 as EnvironmentReturn, a7 as ErrorWithDiff, a as File, n as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, Z as MergeInsertions, a1 as ModuleCache, M as ModuleGraphData, $ as MutableArray, Q as Nullable, a8 as OnServerRestartHandler, a6 as ParsedStack, a5 as Position, b as Reporter, K as ResolveIdFunction, R as ResolvedConfig, ad as ResolvedCoverageOptions, d as RunMode, r as RuntimeContext, u as SnapshotData, x as SnapshotMatchOptions, y as SnapshotResult, w as SnapshotStateOptions, G as SnapshotSummary, v as SnapshotUpdateState, S as Suite, m as SuiteAPI, p as SuiteCollector, q as SuiteFactory, o as SuiteHooks, i as Task, f as TaskBase, g as TaskResult, T as TaskResultPack, e as TaskState, h as Test, l as TestAPI, s as TestContext, j as TestFunction, k as TestOptions, z as UncheckedSnapshot, U as UserConfig, a4 as UserConsoleLog, t as Vitest, V as VitestEnvironment, c as VitestRunMode, W as WorkerContext, O as WorkerGlobalState, N as WorkerRPC } from './global-58e8e951.js';
1
+ import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-2f5b6168.js';
2
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-2f5b6168.js';
3
+ import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-f302dae9.js';
4
+ export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-f302dae9.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
@@ -149,6 +149,15 @@ declare class VitestUtils {
149
149
  * importing a module, that you cannot wait otherwise.
150
150
  */
151
151
  dynamicImportSettled(): Promise<void>;
152
+ private _config;
153
+ /**
154
+ * Updates runtime config. You can only change values that are used when executing tests.
155
+ */
156
+ setConfig(config: RuntimeConfig): void;
157
+ /**
158
+ * If config was changed with `vi.setConfig`, this will reset it to the original state.
159
+ */
160
+ resetConfig(): void;
152
161
  }
153
162
  declare const vitest: VitestUtils;
154
163
  declare const vi: VitestUtils;
package/dist/index.js CHANGED
@@ -1,19 +1,25 @@
1
- export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.37ec5d73.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.d748b085.js';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.e387e274.js';
2
+ import { e as dist } from './chunk-runtime-test-state.4ed42543.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-runtime-test-state.4ed42543.js';
3
4
  import * as chai from 'chai';
4
5
  export { chai };
5
6
  export { assert, should } from 'chai';
6
7
  import 'util';
7
- import './chunk-mock-date.030959d3.js';
8
+ import './chunk-typecheck-constants.4891f22f.js';
8
9
  import 'path';
9
- import './chunk-utils-env.b1281522.js';
10
+ import './chunk-utils-env.03f840f2.js';
10
11
  import 'tty';
11
12
  import 'url';
12
13
  import 'local-pkg';
13
14
  import './vendor-_commonjsHelpers.addc3445.js';
14
- import './chunk-runtime-rpc.b418c0ab.js';
15
- import './chunk-utils-timers.8fca243e.js';
15
+ import './chunk-runtime-rpc.1e7530d3.js';
16
+ import './chunk-utils-timers.06f993db.js';
16
17
  import 'fs';
17
- import './chunk-utils-source-map.663e2952.js';
18
+ import './chunk-utils-source-map.c6dfbbc1.js';
18
19
  import './spy.js';
19
20
  import 'tinyspy';
21
+
22
+
23
+
24
+ var expectTypeOf = dist.expectTypeOf;
25
+ export { expectTypeOf };
package/dist/loader.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { readFile } from 'fs/promises';
3
- import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.2144000e.js';
4
- import { g as getWorkerState } from './chunk-mock-date.030959d3.js';
3
+ import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.8f0b4a12.js';
4
+ import { g as getWorkerState } from './chunk-typecheck-constants.4891f22f.js';
5
5
  import 'fs';
6
- import './chunk-utils-env.b1281522.js';
6
+ import './chunk-utils-env.03f840f2.js';
7
7
  import 'tty';
8
8
  import 'path';
9
+ import 'acorn';
9
10
  import 'module';
10
11
  import 'assert';
11
12
  import 'util';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { c as VitestRunMode, U as UserConfig, t as Vitest, am as ModuleCacheMap, an as ViteNodeRunnerOptions, ao as MockMap, ap as ViteNodeRunner, aq as TestSequencer } from './global-58e8e951.js';
2
- export { aq as TestSequencer, as as TestSequencerConstructor, t as Vitest, ar as startVitest } from './global-58e8e951.js';
1
+ import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as ModuleCacheMap, ay as ViteNodeRunnerOptions, az as MockMap, aA as ViteNodeRunner, aB as TestSequencer } from './types-f302dae9.js';
2
+ export { aB as TestSequencer, aD as TestSequencerConstructor, N as Vitest, aC as startVitest } from './types-f302dae9.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import 'tinybench';
5
5
  import 'fs';
package/dist/node.js CHANGED
@@ -1,14 +1,14 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.d9033432.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.41b92ec9.js';
3
- import './chunk-utils-env.b1281522.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.477f36a4.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.503a4f67.js';
3
+ import './chunk-utils-env.03f840f2.js';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
7
- import './chunk-integrations-coverage.cca09977.js';
7
+ import './chunk-integrations-coverage.befed097.js';
8
8
  import 'local-pkg';
9
- import './chunk-env-node.700b7e95.js';
9
+ import './chunk-env-node.67948209.js';
10
10
  import 'console';
11
- import './chunk-mock-date.030959d3.js';
11
+ import './chunk-typecheck-constants.4891f22f.js';
12
12
  import 'vite';
13
13
  import 'process';
14
14
  import 'fs';
@@ -17,20 +17,27 @@ import 'util';
17
17
  import 'stream';
18
18
  import 'events';
19
19
  import './vendor-_commonjsHelpers.addc3445.js';
20
- import './chunk-vite-node-client.3868b3ba.js';
20
+ import './chunk-vite-node-client.b2ab6dcf.js';
21
21
  import 'module';
22
22
  import 'vm';
23
- import './chunk-vite-node-utils.2144000e.js';
23
+ import './chunk-vite-node-utils.8f0b4a12.js';
24
+ import 'acorn';
24
25
  import 'assert';
25
26
  import 'debug';
26
27
  import 'perf_hooks';
28
+ import 'fs/promises';
29
+ import './vendor-index.737c3cff.js';
30
+ import 'buffer';
31
+ import 'child_process';
32
+ import './vendor-index.e1d4cf84.js';
33
+ import 'source-map';
34
+ import 'acorn-walk';
27
35
  import 'worker_threads';
28
36
  import 'tinypool';
29
- import './chunk-utils-timers.8fca243e.js';
30
- import './chunk-utils-source-map.663e2952.js';
37
+ import './chunk-utils-timers.06f993db.js';
38
+ import './chunk-utils-source-map.c6dfbbc1.js';
31
39
  import 'crypto';
32
40
  import './vendor-index.9c919048.js';
33
- import './vendor-index.1a291e86.js';
34
41
  import './chunk-magic-string.ffe2b171.js';
35
42
  import 'strip-literal';
36
43
  import 'readline';