vitest 0.32.1 → 0.32.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 (42) hide show
  1. package/LICENSE.md +33 -4
  2. package/dist/browser.d.ts +1 -1
  3. package/dist/browser.js +22 -5
  4. package/dist/child.js +3 -3
  5. package/dist/{chunk-api-setup.05e3917b.js → chunk-api-setup.8f785c4a.js} +18 -11
  6. package/dist/{chunk-install-pkg.65daeadb.js → chunk-install-pkg.0716919d.js} +69 -55
  7. package/dist/{chunk-integrations-globals.a56dee90.js → chunk-integrations-globals.0093e2ed.js} +5 -5
  8. package/dist/{chunk-node-git.4c43bd73.js → chunk-node-git.c410fed8.js} +3 -2
  9. package/dist/cli-wrapper.js +2 -2
  10. package/dist/cli.js +8 -8
  11. package/dist/config.d.ts +1 -1
  12. package/dist/coverage.d.ts +1 -1
  13. package/dist/entry.js +9 -9
  14. package/dist/environments.d.ts +1 -1
  15. package/dist/environments.js +1 -1
  16. package/dist/index.d.ts +60 -40
  17. package/dist/index.js +6 -6
  18. package/dist/loader.js +140 -4
  19. package/dist/node.d.ts +3 -3
  20. package/dist/node.js +9 -9
  21. package/dist/runners.d.ts +1 -1
  22. package/dist/runners.js +24 -19
  23. package/dist/suite.d.ts +1 -0
  24. package/dist/{types-2b1c412e.d.ts → types-198fd1d9.d.ts} +302 -77
  25. package/dist/vendor-_commonjsHelpers.7d1333e8.js +7 -0
  26. package/dist/{vendor-cli-api.17011d0a.js → vendor-cli-api.ff679aa2.js} +281 -229
  27. package/dist/{vendor-coverage.de2180ed.js → vendor-coverage.2e41927a.js} +1 -1
  28. package/dist/{vendor-execute.001ae440.js → vendor-execute.3576af13.js} +14 -16
  29. package/dist/{vendor-index.c1e09929.js → vendor-index.1f85e5f1.js} +52 -39
  30. package/dist/{vendor-index.fad2598b.js → vendor-index.23ac4e13.js} +1 -1
  31. package/dist/{vendor-index.0f133dbe.js → vendor-index.2af39fbb.js} +5 -3
  32. package/dist/{vendor-index.fc98d30f.js → vendor-index.98139333.js} +4 -22
  33. package/dist/{vendor-index.87ab04c3.js → vendor-index.cc463d9e.js} +2 -1
  34. package/dist/{vendor-rpc.4d3d7a54.js → vendor-rpc.ad5b08c7.js} +10 -10
  35. package/dist/{vendor-run-once.69ce7172.js → vendor-run-once.1fa85ba7.js} +2 -2
  36. package/dist/vendor-vi.dd6706cb.js +3421 -0
  37. package/dist/worker.js +3 -3
  38. package/package.json +21 -22
  39. package/dist/vendor-_commonjsHelpers.76cdd49e.js +0 -3
  40. package/dist/vendor-setup.common.f1cf2231.js +0 -20
  41. package/dist/vendor-vi.74cf3ef7.js +0 -3354
  42. /package/dist/{vendor-index.75f2b63d.js → vendor-environments.75f2b63d.js} +0 -0
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { normalize } from 'pathe';
2
2
  import cac from 'cac';
3
3
  import c from 'picocolors';
4
- import { v as version, s as startVitest, d as divider } from './vendor-cli-api.17011d0a.js';
5
- import './vendor-index.fad2598b.js';
6
- import { t as toArray } from './vendor-index.87ab04c3.js';
4
+ import { v as version, s as startVitest, d as divider } from './vendor-cli-api.ff679aa2.js';
5
+ import './vendor-index.23ac4e13.js';
6
+ import { t as toArray } from './vendor-index.cc463d9e.js';
7
7
  import './vendor-constants.538d9b49.js';
8
- import './vendor-coverage.de2180ed.js';
9
- import './vendor-index.75f2b63d.js';
8
+ import './vendor-coverage.2e41927a.js';
9
+ import './vendor-environments.75f2b63d.js';
10
10
  import 'node:console';
11
11
  import 'local-pkg';
12
12
  import 'node:url';
@@ -15,13 +15,13 @@ import 'vite';
15
15
  import 'node:path';
16
16
  import 'node:process';
17
17
  import 'node:fs';
18
+ import './vendor-_commonjsHelpers.7d1333e8.js';
18
19
  import 'path';
19
20
  import 'os';
20
21
  import 'util';
21
22
  import 'stream';
22
23
  import 'events';
23
24
  import 'fs';
24
- import './vendor-_commonjsHelpers.76cdd49e.js';
25
25
  import 'vite-node/utils';
26
26
  import 'vite-node/client';
27
27
  import '@vitest/snapshot/manager';
@@ -38,7 +38,7 @@ import './vendor-tasks.f9d75aed.js';
38
38
  import '@vitest/runner/utils';
39
39
  import 'node:module';
40
40
  import 'node:crypto';
41
- import './vendor-index.c1e09929.js';
41
+ import './vendor-index.1f85e5f1.js';
42
42
  import 'node:buffer';
43
43
  import 'child_process';
44
44
  import 'assert';
@@ -55,7 +55,7 @@ import 'readline';
55
55
  import './vendor-global.6795f91f.js';
56
56
 
57
57
  const cli = cac("vitest");
58
- cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--isolate", "Isolate environment for each test file (default: true)").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser api with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).help();
58
+ cli.version(version).option("-r, --root <path>", "Root path").option("-c, --config <path>", "Path to config file").option("-u, --update", "Update snapshot").option("-w, --watch", "Enable watch mode").option("-t, --testNamePattern <pattern>", "Run tests with full names matching the specified regexp pattern").option("--dir <path>", "Base directory to scan for the test files").option("--ui", "Enable UI").option("--open", "Open UI automatically (default: !process.env.CI))").option("--api [api]", "Serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "Enabled threads (default: true)").option("--single-thread", "Run tests inside a single thread, requires --threads (default: false)").option("--silent", "Silent console output from tests").option("--hideSkippedTests", "Hide logs for skipped tests").option("--isolate", "Isolate environment for each test file (default: true)").option("--reporter <name>", "Specify reporters").option("--outputFile <filename/-s>", "Write test results to a file when supporter reporter is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "Enable coverage report").option("--run", "Disable watch mode").option("--mode <name>", "Override Vite mode (default: test)").option("--globals", "Inject apis globally").option("--dom", "Mock browser api with happy-dom").option("--browser [options]", "Run tests in the browser (default: false)").option("--environment <env>", "Specify runner environment, if not running in the browser (default: node)").option("--passWithNoTests", "Pass when no tests found").option("--logHeapUsage", "Show the size of heap for each test").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order, use --sequence.concurrent to run tests in parallel)").option("--segfaultRetry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--no-color", "Removes colors from the console output").option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").option("--test-timeout <time>", "Default timeout of a test in milliseconds (default: 5000)").option("--bail <number>", "Stop test execution when given number of tests have failed", { default: 0 }).option("--retry <times>", "Retry the test specific number of times if it fails", { default: 0 }).help();
59
59
  cli.command("run [...filters]").action(run);
60
60
  cli.command("related [...filters]").action(runRelated);
61
61
  cli.command("watch [...filters]").action(watch);
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv, UserConfig, mergeConfig } from 'vite';
3
- import { a1 as ResolvedCoverageOptions, q as UserConfig, a5 as CoverageV8Options, a4 as CoverageC8Options, a6 as CustomProviderOptions, a3 as CoverageIstanbulOptions, aj as HtmlOptions, ak as FileOptions, al as CloverOptions, am as CoberturaOptions, an as HtmlSpaOptions, ao as LcovOptions, ap as LcovOnlyOptions, aq as TeamcityOptions, ar as TextOptions, as as ProjectOptions, F as FakeTimerInstallOpts, P as ProjectConfig } from './types-2b1c412e.js';
3
+ import { c as ResolvedCoverageOptions, U as UserConfig, d as CoverageV8Options, e as CoverageC8Options, f as CustomProviderOptions, g as CoverageIstanbulOptions, H as HtmlOptions, F as FileOptions, h as CloverOptions, i as CoberturaOptions, j as HtmlSpaOptions, L as LcovOptions, k as LcovOnlyOptions, T as TeamcityOptions, l as TextOptions, P as ProjectOptions, m as FakeTimerInstallOpts, n as ProjectConfig } from './types-198fd1d9.js';
4
4
  import '@vitest/snapshot';
5
5
  import '@vitest/expect';
6
6
  import '@vitest/runner';
@@ -1,4 +1,4 @@
1
- import { a2 as BaseCoverageOptions, a1 as ResolvedCoverageOptions } from './types-2b1c412e.js';
1
+ import { B as BaseCoverageOptions, c as ResolvedCoverageOptions } from './types-198fd1d9.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
package/dist/entry.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests } from '@vitest/runner';
3
3
  import { resolve } from 'pathe';
4
- import { c as resetModules } from './vendor-index.fad2598b.js';
5
- import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.74cf3ef7.js';
4
+ import { r as resetModules } from './vendor-index.23ac4e13.js';
5
+ import { R as RealDate, d as globalExpect, s as setupChaiConfig, v as vi } from './vendor-vi.dd6706cb.js';
6
6
  import { d as distDir } from './vendor-paths.84fc7a99.js';
7
- import { a as startCoverageInsideWorker, t as takeCoverageInsideWorker, s as stopCoverageInsideWorker } from './vendor-coverage.de2180ed.js';
7
+ import { s as startCoverageInsideWorker, t as takeCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.2e41927a.js';
8
8
  import { createRequire } from 'node:module';
9
9
  import { isatty } from 'node:tty';
10
10
  import { installSourcemapsSupport } from 'vite-node/source-map';
11
11
  import { setupColors, createColors, getSafeTimers } from '@vitest/utils';
12
- import { e as environments } from './vendor-index.75f2b63d.js';
12
+ import { e as environments } from './vendor-environments.75f2b63d.js';
13
13
  import { NodeSnapshotEnvironment } from '@vitest/snapshot/environment';
14
- import { r as rpc } from './vendor-rpc.4d3d7a54.js';
15
- import { i as index } from './vendor-index.0f133dbe.js';
16
- import { s as setupCommonEnv } from './vendor-setup.common.f1cf2231.js';
14
+ import { a as rpc } from './vendor-rpc.ad5b08c7.js';
15
+ import { i as index } from './vendor-index.2af39fbb.js';
16
+ import { setupCommonEnv } from './browser.js';
17
17
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
18
18
  import 'std-env';
19
19
  import '@vitest/runner/utils';
20
20
  import 'chai';
21
- import './vendor-_commonjsHelpers.76cdd49e.js';
21
+ import './vendor-_commonjsHelpers.7d1333e8.js';
22
22
  import '@vitest/expect';
23
23
  import '@vitest/snapshot';
24
24
  import '@vitest/utils/error';
@@ -28,7 +28,7 @@ import '@vitest/spy';
28
28
  import 'node:url';
29
29
  import 'node:console';
30
30
  import 'local-pkg';
31
- import './vendor-run-once.69ce7172.js';
31
+ import './vendor-run-once.1fa85ba7.js';
32
32
 
33
33
  class VitestSnapshotEnvironment extends NodeSnapshotEnvironment {
34
34
  getHeader() {
@@ -1,4 +1,4 @@
1
- import { S as Environment } from './types-2b1c412e.js';
1
+ import { E as Environment } from './types-198fd1d9.js';
2
2
  import '@vitest/snapshot';
3
3
  import '@vitest/expect';
4
4
  import 'vite';
@@ -1,3 +1,3 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './vendor-index.75f2b63d.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.75f2b63d.js';
2
2
  import 'node:console';
3
3
  import 'local-pkg';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { File, TaskResultPack, CancelReason } from '@vitest/runner';
2
2
  export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
3
- import { B as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, A as AfterSuiteRunMeta, U as UserConsoleLog, a as ResolvedConfig, b as ModuleGraphData, c as Reporter } from './types-2b1c412e.js';
4
- export { n as ApiConfig, H as ArgumentsType, G as Arrayable, z as Awaitable, a2 as BaseCoverageOptions, aa as BenchFunction, a8 as Benchmark, a9 as BenchmarkResult, a7 as BenchmarkUserOptions, k as BuiltinEnvironment, m as CSSModuleScopeStrategy, C as ChaiConfig, f as CollectLineNumbers, h as CollectLines, L as Constructable, j as Context, v as ContextRPC, u as ContextTestEnvironment, a4 as CoverageC8Options, a3 as CoverageIstanbulOptions, a0 as CoverageOptions, Y as CoverageProvider, _ as CoverageProviderModule, $ as CoverageReporter, a5 as CoverageV8Options, a6 as CustomProviderOptions, D as DepsOptimizationOptions, S as Environment, E as EnvironmentOptions, Q as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, O as ModuleCache, K as MutableArray, N as Nullable, X as OnServerRestartHandler, P as ProjectConfig, e as RawErrsMap, Z as ReportContext, x as ResolveIdFunction, a1 as ResolvedCoverageOptions, i as RootAndTarget, t as RunnerRPC, r as RuntimeRPC, T as TscErrorInfo, p as TypecheckConfig, q as UserConfig, w as Vitest, V as VitestEnvironment, l as VitestPool, o as VitestRunMode, W as WorkerContext, y as WorkerGlobalState, d as createExpect, g as expect, s as setupChaiConfig } from './types-2b1c412e.js';
3
+ import { v as BenchmarkAPI, m as FakeTimerInstallOpts, w as MockFactoryWithHelper, x as RuntimeConfig, A as AfterSuiteRunMeta, y as UserConsoleLog, R as ResolvedConfig, z as ModuleGraphData, D as Reporter } from './types-198fd1d9.js';
4
+ export { a2 as ApiConfig, ah as ArgumentsType, ag as Arrayable, ae as Awaitable, B as BaseCoverageOptions, as as BenchFunction, aq as Benchmark, ar as BenchmarkResult, ap as BenchmarkUserOptions, _ as BuiltinEnvironment, a1 as CSSModuleScopeStrategy, K as ChaiConfig, Q as CollectLineNumbers, S as CollectLines, aj as Constructable, Y as Context, aa as ContextRPC, a9 as ContextTestEnvironment, e as CoverageC8Options, g as CoverageIstanbulOptions, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule, ao as CoverageReporter, d as CoverageV8Options, f as CustomProviderOptions, a4 as DepsOptimizationOptions, E as Environment, a3 as EnvironmentOptions, al as EnvironmentReturn, a5 as InlineConfig, Z as JSDOMOptions, ak as ModuleCache, ai as MutableArray, af as Nullable, am as OnServerRestartHandler, n as ProjectConfig, N as RawErrsMap, an as ReportContext, ac as ResolveIdFunction, c as ResolvedCoverageOptions, X as RootAndTarget, a8 as RunnerRPC, a7 as RuntimeRPC, O as TscErrorInfo, a6 as TypecheckConfig, U as UserConfig, o as Vitest, $ as VitestEnvironment, a0 as VitestPool, V as VitestRunMode, ab as WorkerContext, ad as WorkerGlobalState, I as createExpect, G as expect, J as setupChaiConfig } from './types-198fd1d9.js';
5
5
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, EnhancedSpy } from '@vitest/spy';
6
6
  export { EnhancedSpy, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, SpyInstance } from '@vitest/spy';
7
7
  export { SnapshotEnvironment } from '@vitest/snapshot/environment';
@@ -56,6 +56,7 @@ declare type DeepBrand<T> = IsNever<T> extends true ? {
56
56
  type: 'function';
57
57
  params: DeepBrand<P>;
58
58
  return: DeepBrand<R>;
59
+ this: DeepBrand<ThisParameterType<T>>;
59
60
  } : T extends any[] ? {
60
61
  type: 'array';
61
62
  items: {
@@ -85,52 +86,71 @@ declare type ReadonlyKeys<T> = Extract<{
85
86
  declare type ReadonlyEquivalent<X, Y> = Extends<(<T>() => T extends X ? true : false), (<T>() => T extends Y ? true : false)>;
86
87
  declare type Extends<L, R> = IsNever<L> extends true ? IsNever<R> : [L] extends [R] ? true : false;
87
88
  declare type StrictExtends<L, R> = Extends<DeepBrand<L>, DeepBrand<R>>;
88
- declare type Equal<Left, Right> = And<[StrictExtends<Left, Right>, StrictExtends<Right, Left>]>;
89
+ declare type StrictEqual<L, R> = (<T>() => T extends (L & T) | T ? true : false) extends <T>() => T extends (R & T) | T ? true : false ? IsNever<L> extends IsNever<R> ? true : false : false;
90
+ declare type Equal<Left, Right, Branded = true> = Branded extends true ? And<[StrictExtends<Left, Right>, StrictExtends<Right, Left>]> : StrictEqual<Left, Right>;
89
91
  declare type Params<Actual> = Actual extends (...args: infer P) => any ? P : never;
90
92
  declare type ConstructorParams<Actual> = Actual extends new (...args: infer P) => any ? Actual extends new () => any ? P | [] : P : never;
91
- declare type MismatchArgs<B extends boolean, C extends boolean> = Eq<B, C> extends true ? [] : [never];
92
- interface ExpectTypeOf<Actual, B extends boolean> {
93
- toBeAny: (...MISMATCH: MismatchArgs<IsAny<Actual>, B>) => true;
94
- toBeUnknown: (...MISMATCH: MismatchArgs<IsUnknown<Actual>, B>) => true;
95
- toBeNever: (...MISMATCH: MismatchArgs<IsNever<Actual>, B>) => true;
96
- toBeFunction: (...MISMATCH: MismatchArgs<Extends<Actual, (...args: any[]) => any>, B>) => true;
97
- toBeObject: (...MISMATCH: MismatchArgs<Extends<Actual, object>, B>) => true;
98
- toBeArray: (...MISMATCH: MismatchArgs<Extends<Actual, any[]>, B>) => true;
99
- toBeNumber: (...MISMATCH: MismatchArgs<Extends<Actual, number>, B>) => true;
100
- toBeString: (...MISMATCH: MismatchArgs<Extends<Actual, string>, B>) => true;
101
- toBeBoolean: (...MISMATCH: MismatchArgs<Extends<Actual, boolean>, B>) => true;
102
- toBeVoid: (...MISMATCH: MismatchArgs<Extends<Actual, void>, B>) => true;
103
- toBeSymbol: (...MISMATCH: MismatchArgs<Extends<Actual, symbol>, B>) => true;
104
- toBeNull: (...MISMATCH: MismatchArgs<Extends<Actual, null>, B>) => true;
105
- toBeUndefined: (...MISMATCH: MismatchArgs<Extends<Actual, undefined>, B>) => true;
106
- toBeNullable: (...MISMATCH: MismatchArgs<Not<Equal<Actual, NonNullable<Actual>>>, B>) => true;
93
+ declare type MismatchArgs<ActualResult extends boolean, ExpectedResult extends boolean> = Eq<ActualResult, ExpectedResult> extends true ? [] : [never];
94
+ interface ExpectTypeOfOptions {
95
+ positive: boolean;
96
+ branded: boolean;
97
+ }
98
+ interface ExpectTypeOf<Actual, Options extends ExpectTypeOfOptions> {
99
+ toBeAny: (...MISMATCH: MismatchArgs<IsAny<Actual>, Options['positive']>) => true;
100
+ toBeUnknown: (...MISMATCH: MismatchArgs<IsUnknown<Actual>, Options['positive']>) => true;
101
+ toBeNever: (...MISMATCH: MismatchArgs<IsNever<Actual>, Options['positive']>) => true;
102
+ toBeFunction: (...MISMATCH: MismatchArgs<Extends<Actual, (...args: any[]) => any>, Options['positive']>) => true;
103
+ toBeObject: (...MISMATCH: MismatchArgs<Extends<Actual, object>, Options['positive']>) => true;
104
+ toBeArray: (...MISMATCH: MismatchArgs<Extends<Actual, any[]>, Options['positive']>) => true;
105
+ toBeNumber: (...MISMATCH: MismatchArgs<Extends<Actual, number>, Options['positive']>) => true;
106
+ toBeString: (...MISMATCH: MismatchArgs<Extends<Actual, string>, Options['positive']>) => true;
107
+ toBeBoolean: (...MISMATCH: MismatchArgs<Extends<Actual, boolean>, Options['positive']>) => true;
108
+ toBeVoid: (...MISMATCH: MismatchArgs<Extends<Actual, void>, Options['positive']>) => true;
109
+ toBeSymbol: (...MISMATCH: MismatchArgs<Extends<Actual, symbol>, Options['positive']>) => true;
110
+ toBeNull: (...MISMATCH: MismatchArgs<Extends<Actual, null>, Options['positive']>) => true;
111
+ toBeUndefined: (...MISMATCH: MismatchArgs<Extends<Actual, undefined>, Options['positive']>) => true;
112
+ toBeNullable: (...MISMATCH: MismatchArgs<Not<Equal<Actual, NonNullable<Actual>, Options['branded']>>, Options['positive']>) => true;
107
113
  toMatchTypeOf: {
108
- <Expected>(...MISMATCH: MismatchArgs<Extends<Actual, Expected>, B>): true;
109
- <Expected>(expected: Expected, ...MISMATCH: MismatchArgs<Extends<Actual, Expected>, B>): true;
114
+ <Expected>(...MISMATCH: MismatchArgs<Extends<Actual, Expected>, Options['positive']>): true;
115
+ <Expected>(expected: Expected, ...MISMATCH: MismatchArgs<Extends<Actual, Expected>, Options['positive']>): true;
110
116
  };
111
117
  toEqualTypeOf: {
112
- <Expected>(...MISMATCH: MismatchArgs<Equal<Actual, Expected>, B>): true;
113
- <Expected>(expected: Expected, ...MISMATCH: MismatchArgs<Equal<Actual, Expected>, B>): true;
118
+ <Expected>(...MISMATCH: MismatchArgs<Equal<Actual, Expected, Options['branded']>, Options['positive']>): true;
119
+ <Expected>(expected: Expected, ...MISMATCH: MismatchArgs<Equal<Actual, Expected, Options['branded']>, Options['positive']>): true;
114
120
  };
115
- toBeCallableWith: B extends true ? (...args: Params<Actual>) => true : never;
116
- toBeConstructibleWith: B extends true ? (...args: ConstructorParams<Actual>) => true : never;
117
- toHaveProperty: <K extends string>(key: K, ...MISMATCH: MismatchArgs<Extends<K, keyof Actual>, B>) => K extends keyof Actual ? ExpectTypeOf<Actual[K], B> : true;
118
- extract: <V>(v?: V) => ExpectTypeOf<Extract<Actual, V>, B>;
119
- exclude: <V>(v?: V) => ExpectTypeOf<Exclude<Actual, V>, B>;
120
- parameter: <K extends keyof Params<Actual>>(number: K) => ExpectTypeOf<Params<Actual>[K], B>;
121
- parameters: ExpectTypeOf<Params<Actual>, B>;
122
- constructorParameters: ExpectTypeOf<ConstructorParams<Actual>, B>;
123
- instance: Actual extends new (...args: any[]) => infer I ? ExpectTypeOf<I, B> : never;
124
- returns: Actual extends (...args: any[]) => infer R ? ExpectTypeOf<R, B> : never;
125
- resolves: Actual extends PromiseLike<infer R> ? ExpectTypeOf<R, B> : never;
126
- items: Actual extends ArrayLike<infer R> ? ExpectTypeOf<R, B> : never;
127
- guards: Actual extends (v: any, ...args: any[]) => v is infer T ? ExpectTypeOf<T, B> : never;
128
- asserts: Actual extends (v: any, ...args: any[]) => asserts v is infer T ? unknown extends T ? never : ExpectTypeOf<T, B> : never;
129
- not: ExpectTypeOf<Actual, Not<B>>;
121
+ toBeCallableWith: Options['positive'] extends true ? (...args: Params<Actual>) => true : never;
122
+ toBeConstructibleWith: Options['positive'] extends true ? (...args: ConstructorParams<Actual>) => true : never;
123
+ toHaveProperty: <K extends string>(key: K, ...MISMATCH: MismatchArgs<Extends<K, keyof Actual>, Options['positive']>) => K extends keyof Actual ? ExpectTypeOf<Actual[K], Options> : true;
124
+ extract: <V>(v?: V) => ExpectTypeOf<Extract<Actual, V>, Options>;
125
+ exclude: <V>(v?: V) => ExpectTypeOf<Exclude<Actual, V>, Options>;
126
+ parameter: <K extends keyof Params<Actual>>(number: K) => ExpectTypeOf<Params<Actual>[K], Options>;
127
+ parameters: ExpectTypeOf<Params<Actual>, Options>;
128
+ constructorParameters: ExpectTypeOf<ConstructorParams<Actual>, Options>;
129
+ thisParameter: ExpectTypeOf<ThisParameterType<Actual>, Options>;
130
+ instance: Actual extends new (...args: any[]) => infer I ? ExpectTypeOf<I, Options> : never;
131
+ returns: Actual extends (...args: any[]) => infer R ? ExpectTypeOf<R, Options> : never;
132
+ resolves: Actual extends PromiseLike<infer R> ? ExpectTypeOf<R, Options> : never;
133
+ items: Actual extends ArrayLike<infer R> ? ExpectTypeOf<R, Options> : never;
134
+ guards: Actual extends (v: any, ...args: any[]) => v is infer T ? ExpectTypeOf<T, Options> : never;
135
+ asserts: Actual extends (v: any, ...args: any[]) => asserts v is infer T ? unknown extends T ? never : ExpectTypeOf<T, Options> : never;
136
+ branded: Omit<ExpectTypeOf<Actual, {
137
+ positive: Options['positive'];
138
+ branded: true;
139
+ }>, 'branded'>;
140
+ not: Omit<ExpectTypeOf<Actual, {
141
+ positive: Not<Options['positive']>;
142
+ branded: Options['branded'];
143
+ }>, 'not'>;
130
144
  }
131
145
  declare type _ExpectTypeOf = {
132
- <Actual>(actual: Actual): ExpectTypeOf<Actual, true>;
133
- <Actual>(): ExpectTypeOf<Actual, true>;
146
+ <Actual>(actual: Actual): ExpectTypeOf<Actual, {
147
+ positive: true;
148
+ branded: false;
149
+ }>;
150
+ <Actual>(): ExpectTypeOf<Actual, {
151
+ positive: true;
152
+ branded: false;
153
+ }>;
134
154
  };
135
155
  /**
136
156
  * Similar to Jest's `expect`, but with type-awareness.
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner';
2
- export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.74cf3ef7.js';
3
- export { i as isFirstRun, a as runOnce } from './vendor-run-once.69ce7172.js';
4
- import { d as dist } from './vendor-index.0f133dbe.js';
5
- export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.0f133dbe.js';
2
+ export { e as bench, c as createExpect, d as expect, s as setupChaiConfig, v as vi, f as vitest } from './vendor-vi.dd6706cb.js';
3
+ export { i as isFirstRun, r as runOnce } from './vendor-run-once.1fa85ba7.js';
4
+ import { d as dist } from './vendor-index.2af39fbb.js';
5
+ export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.2af39fbb.js';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
9
9
  import '@vitest/runner/utils';
10
10
  import '@vitest/utils';
11
- import './vendor-index.fad2598b.js';
11
+ import './vendor-index.23ac4e13.js';
12
12
  import 'pathe';
13
13
  import 'std-env';
14
14
  import './vendor-global.6795f91f.js';
15
- import './vendor-_commonjsHelpers.76cdd49e.js';
15
+ import './vendor-_commonjsHelpers.7d1333e8.js';
16
16
  import '@vitest/expect';
17
17
  import '@vitest/snapshot';
18
18
  import '@vitest/utils/error';
package/dist/loader.js CHANGED
@@ -10,7 +10,7 @@ import 'node:path';
10
10
  import v8 from 'node:v8';
11
11
  import { format, inspect } from 'node:util';
12
12
  import { normalizeModuleId } from 'vite-node/utils';
13
- import './vendor-index.fad2598b.js';
13
+ import './vendor-index.23ac4e13.js';
14
14
  import { g as getWorkerState } from './vendor-global.6795f91f.js';
15
15
  import 'std-env';
16
16
  import '@vitest/runner/utils';
@@ -29,10 +29,26 @@ const BUILTIN_MODULES = new Set(builtinModules);
29
29
  * @typedef {Error & ErrnoExceptionFields} ErrnoException
30
30
  */
31
31
 
32
+
32
33
  const isWindows = process$1.platform === 'win32';
33
34
 
34
35
  const own$1 = {}.hasOwnProperty;
35
36
 
37
+ const classRegExp = /^([A-Z][a-z\d]*)+$/;
38
+ // Sorted by a rough estimate on most frequently used entries.
39
+ const kTypes = new Set([
40
+ 'string',
41
+ 'function',
42
+ 'number',
43
+ 'object',
44
+ // Accept 'Function' and 'Object' as alternative to the lower cased version.
45
+ 'Function',
46
+ 'Object',
47
+ 'boolean',
48
+ 'bigint',
49
+ 'symbol'
50
+ ]);
51
+
36
52
  /**
37
53
  * Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
38
54
  * We cannot use Intl.ListFormat because it's not available in
@@ -50,12 +66,101 @@ function formatList(array, type = 'and') {
50
66
  : `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}`
51
67
  }
52
68
 
53
- /** @type {Map<string, MessageFunction|string>} */
69
+ /** @type {Map<string, MessageFunction | string>} */
54
70
  const messages = new Map();
55
71
  const nodeInternalPrefix = '__node_internal_';
56
72
  /** @type {number} */
57
73
  let userStackTraceLimit;
58
74
 
75
+ createError(
76
+ 'ERR_INVALID_ARG_TYPE',
77
+ /**
78
+ * @param {string} name
79
+ * @param {Array<string> | string} expected
80
+ * @param {unknown} actual
81
+ */
82
+ (name, expected, actual) => {
83
+ assert(typeof name === 'string', "'name' must be a string");
84
+ if (!Array.isArray(expected)) {
85
+ expected = [expected];
86
+ }
87
+
88
+ let message = 'The ';
89
+ if (name.endsWith(' argument')) {
90
+ // For cases like 'first argument'
91
+ message += `${name} `;
92
+ } else {
93
+ const type = name.includes('.') ? 'property' : 'argument';
94
+ message += `"${name}" ${type} `;
95
+ }
96
+
97
+ message += 'must be ';
98
+
99
+ /** @type {Array<string>} */
100
+ const types = [];
101
+ /** @type {Array<string>} */
102
+ const instances = [];
103
+ /** @type {Array<string>} */
104
+ const other = [];
105
+
106
+ for (const value of expected) {
107
+ assert(
108
+ typeof value === 'string',
109
+ 'All expected entries have to be of type string'
110
+ );
111
+
112
+ if (kTypes.has(value)) {
113
+ types.push(value.toLowerCase());
114
+ } else if (classRegExp.exec(value) === null) {
115
+ assert(
116
+ value !== 'object',
117
+ 'The value "object" should be written as "Object"'
118
+ );
119
+ other.push(value);
120
+ } else {
121
+ instances.push(value);
122
+ }
123
+ }
124
+
125
+ // Special handle `object` in case other instances are allowed to outline
126
+ // the differences between each other.
127
+ if (instances.length > 0) {
128
+ const pos = types.indexOf('object');
129
+ if (pos !== -1) {
130
+ types.slice(pos, 1);
131
+ instances.push('Object');
132
+ }
133
+ }
134
+
135
+ if (types.length > 0) {
136
+ message += `${types.length > 1 ? 'one of type' : 'of type'} ${formatList(
137
+ types,
138
+ 'or'
139
+ )}`;
140
+ if (instances.length > 0 || other.length > 0) message += ' or ';
141
+ }
142
+
143
+ if (instances.length > 0) {
144
+ message += `an instance of ${formatList(instances, 'or')}`;
145
+ if (other.length > 0) message += ' or ';
146
+ }
147
+
148
+ if (other.length > 0) {
149
+ if (other.length > 1) {
150
+ message += `one of ${formatList(other, 'or')}`;
151
+ } else {
152
+ if (other[0].toLowerCase() !== other[0]) message += 'an ';
153
+ message += `${other[0]}`;
154
+ }
155
+ }
156
+
157
+ message += `. Received ${determineSpecificType(actual)}`;
158
+
159
+ return message
160
+ },
161
+ TypeError
162
+ );
163
+
59
164
  createError(
60
165
  'ERR_INVALID_MODULE_SPECIFIER',
61
166
  /**
@@ -242,7 +347,7 @@ createError(
242
347
  * Utility function for registering the error codes. Only used here. Exported
243
348
  * *only* to allow for testing.
244
349
  * @param {string} sym
245
- * @param {MessageFunction|string} value
350
+ * @param {MessageFunction | string} value
246
351
  * @param {ErrorConstructor} def
247
352
  * @returns {new (...args: Array<any>) => Error}
248
353
  */
@@ -366,7 +471,7 @@ const captureLargerStackTrace = hideStackFrames(
366
471
  */
367
472
  function getMessage(key, args, self) {
368
473
  const message = messages.get(key);
369
- assert(typeof message !== 'undefined', 'expected `message` to be found');
474
+ assert(message !== undefined, 'expected `message` to be found');
370
475
 
371
476
  if (typeof message === 'function') {
372
477
  assert(
@@ -390,6 +495,37 @@ function getMessage(key, args, self) {
390
495
  args.unshift(message);
391
496
  return Reflect.apply(format, null, args)
392
497
  }
498
+
499
+ /**
500
+ * Determine the specific type of a value for type-mismatch errors.
501
+ * @param {unknown} value
502
+ * @returns {string}
503
+ */
504
+ function determineSpecificType(value) {
505
+ if (value === null || value === undefined) {
506
+ return String(value)
507
+ }
508
+
509
+ if (typeof value === 'function' && value.name) {
510
+ return `function ${value.name}`
511
+ }
512
+
513
+ if (typeof value === 'object') {
514
+ if (value.constructor && value.constructor.name) {
515
+ return `an instance of ${value.constructor.name}`
516
+ }
517
+
518
+ return `${inspect(value, {depth: -1})}`
519
+ }
520
+
521
+ let inspected = inspect(value, {colors: false});
522
+
523
+ if (inspected.length > 28) {
524
+ inspected = `${inspected.slice(0, 25)}...`;
525
+ }
526
+
527
+ return `type ${typeof value} (${inspected})`
528
+ }
393
529
  function isNodeBuiltin(id = "") {
394
530
  id = id.replace(/^node:/, "").split("/")[0];
395
531
  return BUILTIN_MODULES.has(id);
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as VitestRunMode, q as UserConfig, w as Vitest, ab as PendingSuiteMock, ac as MockFactory, ad as MockMap, ae as TestSequencer, af as WorkspaceSpec } from './types-2b1c412e.js';
2
- export { ai as TestSequencerConstructor, ag as VitestWorkspace, ah as startVitest } from './types-2b1c412e.js';
1
+ import { V as VitestRunMode, U as UserConfig, o as Vitest, p as PendingSuiteMock, M as MockFactory, q as MockMap, r as TestSequencer, W as WorkspaceSpec } from './types-198fd1d9.js';
2
+ export { u as TestSequencerConstructor, s as VitestWorkspace, t as startVitest } from './types-198fd1d9.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
@@ -19,7 +19,7 @@ declare function createVitest(mode: VitestRunMode, options: UserConfig, viteOver
19
19
 
20
20
  declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin[]>;
21
21
 
22
- declare function registerConsoleShortcuts(ctx: Vitest): void;
22
+ declare function registerConsoleShortcuts(ctx: Vitest): () => void;
23
23
 
24
24
  type Key = string | symbol;
25
25
  declare class VitestMocker {
package/dist/node.js CHANGED
@@ -1,14 +1,14 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-cli-api.17011d0a.js';
2
- export { V as VitestExecutor } from './vendor-execute.001ae440.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-cli-api.ff679aa2.js';
2
+ export { V as VitestExecutor } from './vendor-execute.3576af13.js';
3
3
  import 'pathe';
4
4
  import './vendor-constants.538d9b49.js';
5
- import './vendor-coverage.de2180ed.js';
6
- import './vendor-index.75f2b63d.js';
5
+ import './vendor-coverage.2e41927a.js';
6
+ import './vendor-environments.75f2b63d.js';
7
7
  import 'node:console';
8
8
  import 'local-pkg';
9
9
  import 'node:url';
10
10
  import 'picocolors';
11
- import './vendor-index.fad2598b.js';
11
+ import './vendor-index.23ac4e13.js';
12
12
  import 'std-env';
13
13
  import '@vitest/runner/utils';
14
14
  import '@vitest/utils';
@@ -17,13 +17,13 @@ import 'vite';
17
17
  import 'node:path';
18
18
  import 'node:process';
19
19
  import 'node:fs';
20
+ import './vendor-_commonjsHelpers.7d1333e8.js';
20
21
  import 'path';
21
22
  import 'os';
22
23
  import 'util';
23
24
  import 'stream';
24
25
  import 'events';
25
26
  import 'fs';
26
- import './vendor-_commonjsHelpers.76cdd49e.js';
27
27
  import 'vite-node/utils';
28
28
  import 'vite-node/client';
29
29
  import '@vitest/snapshot/manager';
@@ -31,7 +31,7 @@ import 'vite-node/server';
31
31
  import './vendor-paths.84fc7a99.js';
32
32
  import 'node:v8';
33
33
  import 'node:child_process';
34
- import './vendor-index.87ab04c3.js';
34
+ import './vendor-index.cc463d9e.js';
35
35
  import 'node:worker_threads';
36
36
  import 'node:os';
37
37
  import 'tinypool';
@@ -39,7 +39,7 @@ import 'node:perf_hooks';
39
39
  import './vendor-tasks.f9d75aed.js';
40
40
  import 'node:module';
41
41
  import 'node:crypto';
42
- import './vendor-index.c1e09929.js';
42
+ import './vendor-index.1f85e5f1.js';
43
43
  import 'node:buffer';
44
44
  import 'child_process';
45
45
  import 'assert';
@@ -55,4 +55,4 @@ import 'node:readline';
55
55
  import 'readline';
56
56
  import '@vitest/utils/error';
57
57
  import '@vitest/spy';
58
- import './vendor-rpc.4d3d7a54.js';
58
+ import './vendor-rpc.ad5b08c7.js';
package/dist/runners.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner';
2
- import { a as ResolvedConfig } from './types-2b1c412e.js';
2
+ import { R as ResolvedConfig } from './types-198fd1d9.js';
3
3
  import '@vitest/snapshot';
4
4
  import '@vitest/expect';
5
5
  import 'vite';