vitest 0.21.1 → 0.22.0

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 (43) hide show
  1. package/LICENSE.md +32 -4
  2. package/dist/browser.d.ts +4 -5
  3. package/dist/browser.mjs +8 -9
  4. package/dist/{chunk-api-setup.7a6ba7fb.mjs → chunk-api-setup.ecd02c18.mjs} +8 -7
  5. package/dist/{chunk-constants.26dc9f85.mjs → chunk-constants.d3f8437b.mjs} +4 -4
  6. package/dist/{chunk-install-pkg.6c6dc0c2.mjs → chunk-install-pkg.3aa3eae6.mjs} +3 -2
  7. package/dist/{chunk-defaults.02abff90.mjs → chunk-integrations-coverage.d205bd87.mjs} +23 -152
  8. package/dist/{chunk-integrations-globals.44a8f047.mjs → chunk-integrations-globals.e81d2091.mjs} +7 -6
  9. package/dist/{chunk-mock-date.bc81a3ac.mjs → chunk-mock-date.debe9954.mjs} +6 -67
  10. package/dist/chunk-node-git.71b74da4.mjs +80 -0
  11. package/dist/{chunk-runtime-chain.98d42d89.mjs → chunk-runtime-chain.6e363ba2.mjs} +4 -3
  12. package/dist/{chunk-runtime-error.87a2b5a2.mjs → chunk-runtime-error.975bd80a.mjs} +13 -12
  13. package/dist/{chunk-runtime-hooks.453f8858.mjs → chunk-runtime-hooks.4789e99d.mjs} +3 -3
  14. package/dist/{chunk-runtime-mocker.23b62bfa.mjs → chunk-runtime-mocker.c91d29ce.mjs} +5 -5
  15. package/dist/{chunk-runtime-rpc.b50ab560.mjs → chunk-runtime-rpc.29488183.mjs} +1 -1
  16. package/dist/{chunk-utils-source-map.94107ee8.mjs → chunk-utils-source-map.2a082ffd.mjs} +2 -1
  17. package/dist/{chunk-vite-node-client.fdd9592c.mjs → chunk-vite-node-client.d1ead698.mjs} +2 -2
  18. package/dist/{chunk-vite-node-debug.09afb76f.mjs → chunk-vite-node-debug.ff1d2a9f.mjs} +3 -2
  19. package/dist/{chunk-vite-node-externalize.27aee038.mjs → chunk-vite-node-externalize.3a38c8af.mjs} +153 -35
  20. package/dist/{chunk-vite-node-utils.f34df9d3.mjs → chunk-vite-node-utils.d8e5ff7b.mjs} +42 -8
  21. package/dist/cli-wrapper.mjs +107 -0
  22. package/dist/cli.mjs +15 -13
  23. package/dist/config.cjs +3 -0
  24. package/dist/config.d.ts +6 -3
  25. package/dist/config.mjs +2 -1
  26. package/dist/entry.mjs +8 -9
  27. package/dist/{global-60f880c6.d.ts → global-74489cc9.d.ts} +485 -166
  28. package/dist/{index-4a906fa4.d.ts → index-9eded9ec.d.ts} +2 -50
  29. package/dist/index.d.ts +5 -6
  30. package/dist/index.mjs +6 -5
  31. package/dist/loader.mjs +3 -2
  32. package/dist/node.d.ts +3 -3
  33. package/dist/node.mjs +14 -12
  34. package/dist/suite.mjs +5 -4
  35. package/dist/{vendor-index.61438b77.mjs → vendor-index.29636037.mjs} +1 -61
  36. package/dist/{vendor-index.62ce5c33.mjs → vendor-index.2ae8040a.mjs} +0 -0
  37. package/dist/vendor-index.9d9196cc.mjs +61 -0
  38. package/dist/{chunk-node-git.c2be9c49.mjs → vendor-index.fbec8a81.mjs} +5 -73
  39. package/dist/vendor-picocolors.807856aa.mjs +64 -0
  40. package/dist/worker.mjs +7 -6
  41. package/package.json +6 -10
  42. package/vitest.mjs +1 -1
  43. package/dist/mocker-5e2a8e41.d.ts +0 -3
@@ -1,53 +1,5 @@
1
- import { MessagePort } from 'worker_threads';
2
- import { R as ResolvedConfig, a2 as ViteNodeResolveId, a3 as FetchFunction, a4 as RawSourceMap, a as File, X as UserConsoleLog, T as TaskResultPack, v as SnapshotResult, g as Test, a5 as ModuleCacheMap, k as SuiteAPI, j as TestAPI, m as SuiteHooks, H as HookListener, q as TestContext, S as Suite, l as HookCleanupCallback } from './global-60f880c6.js';
3
- import { M as MockMap } from './mocker-5e2a8e41.js';
4
1
  import { SpyImpl } from 'tinyspy';
5
-
6
- declare type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
7
- declare type ReturnType$1<T> = T extends (...args: any) => infer R ? R : never;
8
- declare type PromisifyFn<T> = ReturnType$1<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType$1<T>>>;
9
- declare type BirpcFn<T> = PromisifyFn<T> & {
10
- /**
11
- * Send event without asking for response
12
- */
13
- asEvent(...args: ArgumentsType<T>): void;
14
- };
15
- declare type BirpcReturn<RemoteFunctions> = {
16
- [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
17
- };
18
-
19
- interface WorkerContext {
20
- workerId: number;
21
- port: MessagePort;
22
- config: ResolvedConfig;
23
- files: string[];
24
- invalidates?: string[];
25
- }
26
- declare type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>;
27
- interface WorkerRPC {
28
- fetch: FetchFunction;
29
- resolveId: ResolveIdFunction;
30
- getSourceMap: (id: string, force?: boolean) => Promise<RawSourceMap | undefined>;
31
- onFinished: (files: File[], errors?: unknown[]) => void;
32
- onWorkerExit: (code?: number) => void;
33
- onPathsCollected: (paths: string[]) => void;
34
- onUserConsoleLog: (log: UserConsoleLog) => void;
35
- onUnhandledRejection: (err: unknown) => void;
36
- onCollected: (files: File[]) => void;
37
- onTaskUpdate: (pack: TaskResultPack[]) => void;
38
- snapshotSaved: (snapshot: SnapshotResult) => void;
39
- resolveSnapshotPath: (testPath: string) => string;
40
- }
41
- interface WorkerGlobalState {
42
- ctx: WorkerContext;
43
- config: ResolvedConfig;
44
- rpc: BirpcReturn<WorkerRPC>;
45
- current?: Test;
46
- filepath?: string;
47
- moduleCache: ModuleCacheMap;
48
- browserHashMap?: Map<string, string>;
49
- mockMap: MockMap;
50
- }
2
+ import { k as SuiteAPI, j as TestAPI, m as SuiteHooks, H as HookListener, q as TestContext, S as Suite, l as HookCleanupCallback, g as Test } from './global-74489cc9.js';
51
3
 
52
4
  interface MockResultReturn<T> {
53
5
  type: 'return';
@@ -161,4 +113,4 @@ declare const afterEach: <ExtraContext = {}>(fn: HookListener<[TestContext & Ext
161
113
  declare function createExpect(test?: Test): Vi.ExpectStatic;
162
114
  declare const globalExpect: Vi.ExpectStatic;
163
115
 
164
- export { EnhancedSpy as E, MaybeMockedDeep as M, ResolveIdFunction as R, SpyInstance as S, WorkerContext as W, MaybeMocked as a, MaybePartiallyMocked as b, MaybePartiallyMockedDeep as c, suite as d, describe as e, fn as f, beforeAll as g, afterAll as h, it as i, beforeEach as j, afterEach as k, globalExpect as l, createExpect as m, MockedFunction as n, MockedObject as o, MockInstance as p, Mock as q, MockContext as r, spyOn as s, test as t, Mocked as u, MockedClass as v, WorkerRPC as w, WorkerGlobalState as x };
116
+ export { 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, beforeAll as g, afterAll as h, it as i, beforeEach as j, afterEach as k, globalExpect as l, createExpect as m, MockedFunction as n, MockedObject as o, MockInstance as p, Mock as q, MockContext as r, spyOn as s, test as t, Mocked as u, MockedClass as v };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,13 @@
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-4a906fa4.js';
2
- export { E as EnhancedSpy, q as Mock, r as MockContext, p as MockInstance, u as Mocked, v as MockedClass, n as MockedFunction, o as MockedObject, R as ResolveIdFunction, S as SpyInstance, W as WorkerContext, x as WorkerGlobalState, w as WorkerRPC, h as afterAll, k as afterEach, g as beforeAll, j as beforeEach, m as createExpect, e as describe, l as expect, i as it, d as suite, t as test } from './index-4a906fa4.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-60f880c6.js';
4
- export { A as ApiConfig, C as ArgumentsType, z as Arrayable, y as Awaitable, B as BuiltinEnvironment, a0 as C8Options, O as Constructable, $ as CoverageReporter, K as DeepMerge, D as DoneCallback, W as Environment, E as EnvironmentOptions, Q as EnvironmentReturn, _ as ErrorWithDiff, a as File, l as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, G as MergeInsertions, P as ModuleCache, M as ModuleGraphData, L as MutableArray, N as Nullable, Z as ParsedStack, Y as Position, b as Reporter, a1 as ResolvedC8Options, R as ResolvedConfig, c as RunMode, p as RuntimeContext, r as SnapshotData, u as SnapshotMatchOptions, v as SnapshotResult, t as SnapshotStateOptions, x as SnapshotSummary, s as SnapshotUpdateState, S as Suite, k as SuiteAPI, n as SuiteCollector, o as SuiteFactory, m as SuiteHooks, h as Task, e as TaskBase, f as TaskResult, T as TaskResultPack, d as TaskState, g as Test, j as TestAPI, q as TestContext, i as TestFunction, w as UncheckedSnapshot, U as UserConfig, X as UserConsoleLog, V as Vitest } from './global-60f880c6.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-9eded9ec.js';
2
+ export { E as EnhancedSpy, q as Mock, r as MockContext, p as MockInstance, u as Mocked, v as MockedClass, n as MockedFunction, o as MockedObject, S as SpyInstance, h as afterAll, k as afterEach, g as beforeAll, j as beforeEach, m as createExpect, e as describe, l as expect, i as it, d as suite, t as test } from './index-9eded9ec.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-74489cc9.js';
4
+ export { z as AfterSuiteRunMeta, A as ApiConfig, O as ArgumentsType, L as Arrayable, K as Awaitable, a9 as BaseCoverageOptions, B as BuiltinEnvironment, Y as Constructable, ab as CoverageC8Options, aa as CoverageIstanbulOptions, a7 as CoverageOptions, a4 as CoverageProvider, a5 as CoverageProviderModule, a6 as CoverageReporter, Q as DeepMerge, D as DoneCallback, $ as Environment, E as EnvironmentOptions, _ as EnvironmentReturn, a3 as ErrorWithDiff, a as File, l as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, P as MergeInsertions, Z as ModuleCache, M as ModuleGraphData, X as MutableArray, N as Nullable, a2 as ParsedStack, a1 as Position, b as Reporter, y as ResolveIdFunction, R as ResolvedConfig, a8 as ResolvedCoverageOptions, c as RunMode, p as RuntimeContext, r as SnapshotData, u as SnapshotMatchOptions, v as SnapshotResult, t as SnapshotStateOptions, x as SnapshotSummary, s as SnapshotUpdateState, S as Suite, k as SuiteAPI, n as SuiteCollector, o as SuiteFactory, m as SuiteHooks, h as Task, e as TaskBase, f as TaskResult, T as TaskResultPack, d as TaskState, g as Test, j as TestAPI, q as TestContext, i as TestFunction, w as UncheckedSnapshot, U as UserConfig, a0 as UserConsoleLog, V as Vitest, W as WorkerContext, G as WorkerGlobalState, C as WorkerRPC } from './global-74489cc9.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
8
8
  export { assert, should } from 'chai';
9
- import 'worker_threads';
10
- import './mocker-5e2a8e41.js';
11
9
  import 'tinyspy';
10
+ import 'worker_threads';
12
11
  import 'fs';
13
12
 
14
13
  /**
package/dist/index.mjs CHANGED
@@ -1,18 +1,19 @@
1
- export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.98d42d89.mjs';
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.453f8858.mjs';
1
+ export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.6e363ba2.mjs';
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.4789e99d.mjs';
3
3
  import * as chai from 'chai';
4
4
  export { chai };
5
5
  export { assert, should } from 'chai';
6
6
  import 'util';
7
- import './chunk-mock-date.bc81a3ac.mjs';
7
+ import './chunk-mock-date.debe9954.mjs';
8
8
  import 'path';
9
+ import './vendor-picocolors.807856aa.mjs';
9
10
  import 'tty';
10
11
  import 'local-pkg';
11
12
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.b50ab560.mjs';
13
+ import './chunk-runtime-rpc.29488183.mjs';
13
14
  import './chunk-utils-global.fa20c2f6.mjs';
14
15
  import './chunk-utils-timers.b48455ed.mjs';
15
16
  import 'fs';
16
- import './chunk-utils-source-map.94107ee8.mjs';
17
+ import './chunk-utils-source-map.2a082ffd.mjs';
17
18
  import './spy.mjs';
18
19
  import 'tinyspy';
package/dist/loader.mjs CHANGED
@@ -1,13 +1,14 @@
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.f34df9d3.mjs';
4
- import './chunk-mock-date.bc81a3ac.mjs';
3
+ import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.d8e5ff7b.mjs';
4
+ import './chunk-mock-date.debe9954.mjs';
5
5
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
6
6
  import 'module';
7
7
  import 'fs';
8
8
  import 'path';
9
9
  import 'assert';
10
10
  import 'util';
11
+ import './vendor-picocolors.807856aa.mjs';
11
12
  import 'tty';
12
13
  import 'local-pkg';
13
14
 
package/dist/node.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { U as UserConfig, V as Vitest, a5 as ModuleCacheMap, a6 as ViteNodeRunnerOptions, a7 as ViteNodeRunner, a8 as TestSequencer } from './global-60f880c6.js';
2
- export { a8 as TestSequencer, aa as TestSequencerConstructor, V as Vitest, a9 as startVitest } from './global-60f880c6.js';
1
+ import { U as UserConfig, V as Vitest, ac as ModuleCacheMap, ad as ViteNodeRunnerOptions, ae as MockMap, af as ViteNodeRunner, ag as TestSequencer } from './global-74489cc9.js';
2
+ export { ag as TestSequencer, ai as TestSequencerConstructor, V as Vitest, ah as startVitest } from './global-74489cc9.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
- import { M as MockMap } from './mocker-5e2a8e41.js';
4
+ import 'worker_threads';
5
5
  import 'fs';
6
6
 
7
7
  declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1): Promise<Vitest>;
package/dist/node.mjs CHANGED
@@ -1,33 +1,35 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.27aee038.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.23b62bfa.mjs';
3
- import './chunk-mock-date.bc81a3ac.mjs';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.3a38c8af.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.c91d29ce.mjs';
3
+ import './chunk-mock-date.debe9954.mjs';
4
4
  import 'path';
5
+ import './vendor-picocolors.807856aa.mjs';
5
6
  import 'tty';
6
7
  import 'local-pkg';
7
- import './chunk-defaults.02abff90.mjs';
8
- import 'fs';
9
- import 'module';
10
- import 'url';
8
+ import './chunk-integrations-coverage.d205bd87.mjs';
11
9
  import 'vite';
10
+ import 'url';
12
11
  import 'process';
13
- import './chunk-constants.26dc9f85.mjs';
12
+ import 'fs';
13
+ import './chunk-constants.d3f8437b.mjs';
14
14
  import 'os';
15
15
  import 'util';
16
16
  import 'stream';
17
17
  import 'events';
18
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
19
- import './chunk-vite-node-client.fdd9592c.mjs';
19
+ import './chunk-vite-node-client.d1ead698.mjs';
20
+ import 'module';
20
21
  import 'vm';
21
- import './chunk-vite-node-utils.f34df9d3.mjs';
22
+ import './chunk-vite-node-utils.d8e5ff7b.mjs';
22
23
  import 'assert';
23
24
  import 'debug';
24
25
  import 'worker_threads';
25
26
  import 'tinypool';
26
27
  import 'perf_hooks';
27
- import './chunk-utils-source-map.94107ee8.mjs';
28
+ import './chunk-utils-source-map.2a082ffd.mjs';
28
29
  import './chunk-utils-timers.b48455ed.mjs';
29
30
  import 'crypto';
30
- import './vendor-index.61438b77.mjs';
31
+ import './vendor-index.9d9196cc.mjs';
32
+ import './vendor-index.29636037.mjs';
31
33
  import './chunk-magic-string.efe26975.mjs';
32
34
  import 'readline';
33
35
  import './vendor-index.ae96af6e.mjs';
package/dist/suite.mjs CHANGED
@@ -1,15 +1,16 @@
1
1
  import 'util';
2
- import './chunk-mock-date.bc81a3ac.mjs';
3
- export { e as clearCollectorContext, o as createSuiteHooks, f as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.98d42d89.mjs';
2
+ import './chunk-mock-date.debe9954.mjs';
3
+ export { e as clearCollectorContext, o as createSuiteHooks, f as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.6e363ba2.mjs';
4
4
  import './chunk-utils-global.fa20c2f6.mjs';
5
5
  import 'path';
6
+ import './vendor-picocolors.807856aa.mjs';
6
7
  import 'tty';
7
8
  import 'local-pkg';
8
9
  import 'chai';
9
10
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
10
- import './chunk-runtime-rpc.b50ab560.mjs';
11
+ import './chunk-runtime-rpc.29488183.mjs';
11
12
  import './chunk-utils-timers.b48455ed.mjs';
12
13
  import 'fs';
13
- import './chunk-utils-source-map.94107ee8.mjs';
14
+ import './chunk-utils-source-map.2a082ffd.mjs';
14
15
  import './spy.mjs';
15
16
  import 'tinyspy';
@@ -2,66 +2,6 @@ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
2
2
  import assert$1 from 'assert';
3
3
  import require$$2 from 'events';
4
4
 
5
- var onetime$1 = {exports: {}};
6
-
7
- var mimicFn$2 = {exports: {}};
8
-
9
- const mimicFn$1 = (to, from) => {
10
- for (const prop of Reflect.ownKeys(from)) {
11
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
12
- }
13
-
14
- return to;
15
- };
16
-
17
- mimicFn$2.exports = mimicFn$1;
18
- // TODO: Remove this for the next major release
19
- mimicFn$2.exports.default = mimicFn$1;
20
-
21
- const mimicFn = mimicFn$2.exports;
22
-
23
- const calledFunctions = new WeakMap();
24
-
25
- const onetime = (function_, options = {}) => {
26
- if (typeof function_ !== 'function') {
27
- throw new TypeError('Expected a function');
28
- }
29
-
30
- let returnValue;
31
- let callCount = 0;
32
- const functionName = function_.displayName || function_.name || '<anonymous>';
33
-
34
- const onetime = function (...arguments_) {
35
- calledFunctions.set(onetime, ++callCount);
36
-
37
- if (callCount === 1) {
38
- returnValue = function_.apply(this, arguments_);
39
- function_ = null;
40
- } else if (options.throw === true) {
41
- throw new Error(`Function \`${functionName}\` can only be called once`);
42
- }
43
-
44
- return returnValue;
45
- };
46
-
47
- mimicFn(onetime, function_);
48
- calledFunctions.set(onetime, callCount);
49
-
50
- return onetime;
51
- };
52
-
53
- onetime$1.exports = onetime;
54
- // TODO: Remove this for the next major release
55
- onetime$1.exports.default = onetime;
56
-
57
- onetime$1.exports.callCount = function_ => {
58
- if (!calledFunctions.has(function_)) {
59
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
60
- }
61
-
62
- return calledFunctions.get(function_);
63
- };
64
-
65
5
  var signalExit = {exports: {}};
66
6
 
67
7
  var signals$1 = {exports: {}};
@@ -332,4 +272,4 @@ if (!processOk(process$1)) {
332
272
  };
333
273
  }
334
274
 
335
- export { onetime$1 as o, signalExit as s };
275
+ export { signalExit as s };
@@ -0,0 +1,61 @@
1
+ var onetime$1 = {exports: {}};
2
+
3
+ var mimicFn$2 = {exports: {}};
4
+
5
+ const mimicFn$1 = (to, from) => {
6
+ for (const prop of Reflect.ownKeys(from)) {
7
+ Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
8
+ }
9
+
10
+ return to;
11
+ };
12
+
13
+ mimicFn$2.exports = mimicFn$1;
14
+ // TODO: Remove this for the next major release
15
+ mimicFn$2.exports.default = mimicFn$1;
16
+
17
+ const mimicFn = mimicFn$2.exports;
18
+
19
+ const calledFunctions = new WeakMap();
20
+
21
+ const onetime = (function_, options = {}) => {
22
+ if (typeof function_ !== 'function') {
23
+ throw new TypeError('Expected a function');
24
+ }
25
+
26
+ let returnValue;
27
+ let callCount = 0;
28
+ const functionName = function_.displayName || function_.name || '<anonymous>';
29
+
30
+ const onetime = function (...arguments_) {
31
+ calledFunctions.set(onetime, ++callCount);
32
+
33
+ if (callCount === 1) {
34
+ returnValue = function_.apply(this, arguments_);
35
+ function_ = null;
36
+ } else if (options.throw === true) {
37
+ throw new Error(`Function \`${functionName}\` can only be called once`);
38
+ }
39
+
40
+ return returnValue;
41
+ };
42
+
43
+ mimicFn(onetime, function_);
44
+ calledFunctions.set(onetime, callCount);
45
+
46
+ return onetime;
47
+ };
48
+
49
+ onetime$1.exports = onetime;
50
+ // TODO: Remove this for the next major release
51
+ onetime$1.exports.default = onetime;
52
+
53
+ onetime$1.exports.callCount = function_ => {
54
+ if (!calledFunctions.has(function_)) {
55
+ throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
56
+ }
57
+
58
+ return calledFunctions.get(function_);
59
+ };
60
+
61
+ export { onetime$1 as o };
@@ -1,20 +1,11 @@
1
- import { y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
2
1
  import { Buffer } from 'buffer';
3
2
  import path from 'path';
4
3
  import childProcess from 'child_process';
5
4
  import process$1 from 'process';
6
- import { m as mergeStream, g as getStream, c as crossSpawn } from './vendor-index.62ce5c33.mjs';
7
- import _url from 'url';
5
+ import { m as mergeStream, g as getStream, c as crossSpawn } from './vendor-index.2ae8040a.mjs';
6
+ import url from 'url';
8
7
  import require$$0, { constants } from 'os';
9
- import { s as signalExit } from './vendor-index.61438b77.mjs';
10
- import 'tty';
11
- import 'local-pkg';
12
- import './vendor-_commonjsHelpers.4da45ef5.mjs';
13
- import 'fs';
14
- import 'stream';
15
- import 'util';
16
- import 'assert';
17
- import 'events';
8
+ import { s as signalExit } from './vendor-index.29636037.mjs';
18
9
 
19
10
  function stripFinalNewline(input) {
20
11
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -52,7 +43,7 @@ function npmRunPath(options = {}) {
52
43
  } = options;
53
44
 
54
45
  let previous;
55
- const cwdString = cwd instanceof URL ? _url.fileURLToPath(cwd) : cwd;
46
+ const cwdString = cwd instanceof URL ? url.fileURLToPath(cwd) : cwd;
56
47
  let cwdPath = path.resolve(cwdString);
57
48
  const result = [];
58
49
 
@@ -1077,63 +1068,4 @@ function execa(file, args, options) {
1077
1068
  return mergePromise(spawned, handlePromiseOnce);
1078
1069
  }
1079
1070
 
1080
- class VitestGit {
1081
- constructor(cwd) {
1082
- this.cwd = cwd;
1083
- }
1084
- async resolveFilesWithGitCommand(args) {
1085
- let result;
1086
- try {
1087
- result = await execa("git", args, { cwd: this.root });
1088
- } catch (e) {
1089
- e.message = e.stderr;
1090
- throw e;
1091
- }
1092
- return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
1093
- }
1094
- async findChangedFiles(options) {
1095
- const root = await this.getRoot(this.cwd);
1096
- if (!root)
1097
- return null;
1098
- this.root = root;
1099
- const changedSince = options.changedSince;
1100
- if (typeof changedSince === "string") {
1101
- const [committed, staged2, unstaged2] = await Promise.all([
1102
- this.getFilesSince(changedSince),
1103
- this.getStagedFiles(),
1104
- this.getUnstagedFiles()
1105
- ]);
1106
- return [...committed, ...staged2, ...unstaged2];
1107
- }
1108
- const [staged, unstaged] = await Promise.all([
1109
- this.getStagedFiles(),
1110
- this.getUnstagedFiles()
1111
- ]);
1112
- return [...staged, ...unstaged];
1113
- }
1114
- getFilesSince(hash) {
1115
- return this.resolveFilesWithGitCommand(["diff", "--name-only", `${hash}...HEAD`]);
1116
- }
1117
- getStagedFiles() {
1118
- return this.resolveFilesWithGitCommand(["diff", "--cached", "--name-only"]);
1119
- }
1120
- getUnstagedFiles() {
1121
- return this.resolveFilesWithGitCommand([
1122
- "ls-files",
1123
- "--other",
1124
- "--modified",
1125
- "--exclude-standard"
1126
- ]);
1127
- }
1128
- async getRoot(cwd) {
1129
- const options = ["rev-parse", "--show-cdup"];
1130
- try {
1131
- const result = await execa("git", options, { cwd });
1132
- return resolve(cwd, result.stdout);
1133
- } catch {
1134
- return null;
1135
- }
1136
- }
1137
- }
1138
-
1139
- export { VitestGit };
1071
+ export { execa as e };
@@ -0,0 +1,64 @@
1
+ import require$$0 from 'tty';
2
+
3
+ var picocolors = {exports: {}};
4
+
5
+ let tty = require$$0;
6
+
7
+ let isColorSupported =
8
+ !("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
9
+ ("FORCE_COLOR" in process.env ||
10
+ process.argv.includes("--color") ||
11
+ process.platform === "win32" ||
12
+ (tty.isatty(1) && process.env.TERM !== "dumb") ||
13
+ "CI" in process.env);
14
+
15
+ let formatter =
16
+ (open, close, replace = open) =>
17
+ input => {
18
+ let string = "" + input;
19
+ let index = string.indexOf(close, open.length);
20
+ return ~index
21
+ ? open + replaceClose(string, close, replace, index) + close
22
+ : open + string + close
23
+ };
24
+
25
+ let replaceClose = (string, close, replace, index) => {
26
+ let start = string.substring(0, index) + replace;
27
+ let end = string.substring(index + close.length);
28
+ let nextIndex = end.indexOf(close);
29
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end
30
+ };
31
+
32
+ let createColors = (enabled = isColorSupported) => ({
33
+ isColorSupported: enabled,
34
+ reset: enabled ? s => `\x1b[0m${s}\x1b[0m` : String,
35
+ bold: enabled ? formatter("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m") : String,
36
+ dim: enabled ? formatter("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m") : String,
37
+ italic: enabled ? formatter("\x1b[3m", "\x1b[23m") : String,
38
+ underline: enabled ? formatter("\x1b[4m", "\x1b[24m") : String,
39
+ inverse: enabled ? formatter("\x1b[7m", "\x1b[27m") : String,
40
+ hidden: enabled ? formatter("\x1b[8m", "\x1b[28m") : String,
41
+ strikethrough: enabled ? formatter("\x1b[9m", "\x1b[29m") : String,
42
+ black: enabled ? formatter("\x1b[30m", "\x1b[39m") : String,
43
+ red: enabled ? formatter("\x1b[31m", "\x1b[39m") : String,
44
+ green: enabled ? formatter("\x1b[32m", "\x1b[39m") : String,
45
+ yellow: enabled ? formatter("\x1b[33m", "\x1b[39m") : String,
46
+ blue: enabled ? formatter("\x1b[34m", "\x1b[39m") : String,
47
+ magenta: enabled ? formatter("\x1b[35m", "\x1b[39m") : String,
48
+ cyan: enabled ? formatter("\x1b[36m", "\x1b[39m") : String,
49
+ white: enabled ? formatter("\x1b[37m", "\x1b[39m") : String,
50
+ gray: enabled ? formatter("\x1b[90m", "\x1b[39m") : String,
51
+ bgBlack: enabled ? formatter("\x1b[40m", "\x1b[49m") : String,
52
+ bgRed: enabled ? formatter("\x1b[41m", "\x1b[49m") : String,
53
+ bgGreen: enabled ? formatter("\x1b[42m", "\x1b[49m") : String,
54
+ bgYellow: enabled ? formatter("\x1b[43m", "\x1b[49m") : String,
55
+ bgBlue: enabled ? formatter("\x1b[44m", "\x1b[49m") : String,
56
+ bgMagenta: enabled ? formatter("\x1b[45m", "\x1b[49m") : String,
57
+ bgCyan: enabled ? formatter("\x1b[46m", "\x1b[49m") : String,
58
+ bgWhite: enabled ? formatter("\x1b[47m", "\x1b[49m") : String,
59
+ });
60
+
61
+ picocolors.exports = createColors();
62
+ picocolors.exports.createColors = createColors;
63
+
64
+ export { picocolors as p };
package/dist/worker.mjs CHANGED
@@ -1,17 +1,18 @@
1
- import { y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.fdd9592c.mjs';
1
+ import { x as resolve } from './chunk-mock-date.debe9954.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.d1ead698.mjs';
3
3
  import { workerId } from 'tinypool';
4
- import { d as distDir } from './chunk-constants.26dc9f85.mjs';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.23b62bfa.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.b50ab560.mjs';
4
+ import { d as distDir } from './chunk-constants.d3f8437b.mjs';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.c91d29ce.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.29488183.mjs';
7
7
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
8
8
  import 'path';
9
+ import './vendor-picocolors.807856aa.mjs';
9
10
  import 'tty';
10
11
  import 'local-pkg';
11
12
  import 'module';
12
13
  import 'url';
13
14
  import 'vm';
14
- import './chunk-vite-node-utils.f34df9d3.mjs';
15
+ import './chunk-vite-node-utils.d8e5ff7b.mjs';
15
16
  import 'fs';
16
17
  import 'assert';
17
18
  import 'util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -16,6 +16,7 @@
16
16
  "keywords": [
17
17
  "vite",
18
18
  "vite-node",
19
+ "vitest",
19
20
  "test",
20
21
  "jest"
21
22
  ],
@@ -65,7 +66,6 @@
65
66
  "@edge-runtime/vm": "*",
66
67
  "@vitest/browser": "*",
67
68
  "@vitest/ui": "*",
68
- "c8": "*",
69
69
  "happy-dom": "*",
70
70
  "jsdom": "*"
71
71
  },
@@ -76,9 +76,6 @@
76
76
  "@vitest/browser": {
77
77
  "optional": true
78
78
  },
79
- "c8": {
80
- "optional": true
81
- },
82
79
  "happy-dom": {
83
80
  "optional": true
84
81
  },
@@ -110,9 +107,8 @@
110
107
  "@types/natural-compare": "^1.4.1",
111
108
  "@types/prompts": "^2.4.0",
112
109
  "@types/sinonjs__fake-timers": "^8.1.2",
113
- "@vitest/ui": "0.21.1",
110
+ "@vitest/ui": "0.22.0",
114
111
  "birpc": "^0.2.3",
115
- "c8": "^7.12.0",
116
112
  "cac": "^6.7.12",
117
113
  "chai-subset": "^1.6.0",
118
114
  "cli-truncate": "^3.1.0",
@@ -126,7 +122,7 @@
126
122
  "log-update": "^5.0.1",
127
123
  "magic-string": "^0.26.2",
128
124
  "micromatch": "^4.0.5",
129
- "mlly": "^0.5.7",
125
+ "mlly": "^0.5.12",
130
126
  "natural-compare": "^1.4.0",
131
127
  "p-limit": "^4.0.0",
132
128
  "pathe": "^0.2.0",
@@ -134,11 +130,11 @@
134
130
  "pkg-types": "^0.3.3",
135
131
  "pretty-format": "^27.5.1",
136
132
  "prompts": "^2.4.2",
137
- "rollup": "^2.77.2",
133
+ "rollup": "^2.77.3",
138
134
  "source-map-js": "^1.0.2",
139
135
  "strip-ansi": "^7.0.1",
140
136
  "typescript": "^4.7.4",
141
- "vite-node": "0.21.1",
137
+ "vite-node": "0.22.0",
142
138
  "ws": "^8.8.1"
143
139
  },
144
140
  "scripts": {
package/vitest.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import './dist/cli.mjs'
2
+ import './dist/cli-wrapper.mjs'
@@ -1,3 +0,0 @@
1
- declare type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
2
-
3
- export { MockMap as M };