vitest 2.1.1 → 2.1.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 (57) hide show
  1. package/LICENSE.md +320 -30
  2. package/dist/browser.d.ts +5 -5
  3. package/dist/browser.js +1 -1
  4. package/dist/chunks/{base.CsQmmYBA.js → base.BO5Jx7vw.js} +1 -1
  5. package/dist/chunks/{base.BlXpj3e_.js → base.DwXGwWst.js} +1 -10
  6. package/dist/chunks/{benchmark.puBFxyfE.d.ts → benchmark.JVlTzojj.d.ts} +2 -0
  7. package/dist/chunks/{cac.BVmpoFAv.js → cac.BSMVokHR.js} +7 -7
  8. package/dist/chunks/cli-api.btGgw3PC.js +11819 -0
  9. package/dist/chunks/{config.CHuotKvS.d.ts → config.Crbj2GAb.d.ts} +3 -0
  10. package/dist/chunks/{console.DI3gHgtH.js → console.CfT1Wjed.js} +1 -1
  11. package/dist/chunks/{creator.BteLTfY8.js → creator.CBPphXqR.js} +4 -7
  12. package/dist/chunks/{environment.C5eAp3K6.d.ts → environment.CzISCQ7o.d.ts} +1 -0
  13. package/dist/chunks/{globals.C03P0O1a.js → globals.Bdzt04Qm.js} +3 -3
  14. package/dist/chunks/index.-d_XpZEA.js +140 -0
  15. package/dist/chunks/{index.DkN6V87F.js → index.4GFF2h22.js} +2 -1
  16. package/dist/chunks/{index.zPibhCkV.js → index.Dz2opmmU.js} +653 -585
  17. package/dist/chunks/{index.Bn75ITYg.js → index.X0nbfr6-.js} +37 -28
  18. package/dist/chunks/{reporters.WnPwkmgA.d.ts → reporters.C4ZHgdxQ.d.ts} +20 -15
  19. package/dist/chunks/{resolveConfig.-K5hHm0S.js → resolveConfig.Dha6ilPI.js} +3544 -3374
  20. package/dist/chunks/{runBaseTests.9YDrdSI4.js → runBaseTests.Cx4wXyTR.js} +6 -6
  21. package/dist/chunks/{setup-common.DV1PI68g.js → setup-common.BKyF15v_.js} +1 -1
  22. package/dist/chunks/{suite.CcK46U-P.d.ts → suite.BMWOKiTe.d.ts} +1 -1
  23. package/dist/chunks/{utils.Dbnmsfq1.js → utils.CY6Spixo.js} +26 -47
  24. package/dist/chunks/vi.BskyZC5g.js +3945 -0
  25. package/dist/chunks/{vite.D2yAwzwa.d.ts → vite.YH7MrecS.d.ts} +1 -1
  26. package/dist/chunks/{vm.CPXwWp4C.js → vm.DB_hLchi.js} +1 -1
  27. package/dist/chunks/{worker.CmPmTxgH.d.ts → worker.B6RjTtbk.d.ts} +42 -28
  28. package/dist/chunks/{worker.Bws9Zuxu.d.ts → worker.CcJLfX8w.d.ts} +1 -1
  29. package/dist/cli.js +2 -2
  30. package/dist/config.cjs +2 -1
  31. package/dist/config.d.ts +19 -14
  32. package/dist/config.js +2 -1
  33. package/dist/coverage.d.ts +67 -30
  34. package/dist/coverage.js +250 -109
  35. package/dist/environments.d.ts +2 -2
  36. package/dist/execute.d.ts +3 -3
  37. package/dist/index.d.ts +36 -19
  38. package/dist/index.js +5 -5
  39. package/dist/node.d.ts +8 -8
  40. package/dist/node.js +10 -9
  41. package/dist/reporters.d.ts +4 -4
  42. package/dist/reporters.js +4 -3
  43. package/dist/runners.d.ts +1 -1
  44. package/dist/runners.js +8 -2
  45. package/dist/suite.d.ts +2 -2
  46. package/dist/worker.js +11 -3
  47. package/dist/workers/forks.js +1 -1
  48. package/dist/workers/runVmTests.js +8 -5
  49. package/dist/workers/threads.js +1 -1
  50. package/dist/workers/vmForks.js +2 -2
  51. package/dist/workers/vmThreads.js +2 -2
  52. package/dist/workers.d.ts +4 -4
  53. package/dist/workers.js +4 -4
  54. package/package.json +12 -13
  55. package/dist/chunks/cli-api.BKkmK21J.js +0 -11404
  56. package/dist/chunks/index.iyKRMe3s.js +0 -131
  57. package/dist/chunks/vi.D6IHiKAI.js +0 -3746
@@ -185,6 +185,9 @@ interface SerializedConfig {
185
185
  standalone: boolean;
186
186
  logHeapUsage: boolean | undefined;
187
187
  coverage: SerializedCoverageConfig;
188
+ benchmark?: {
189
+ includeSamples: boolean;
190
+ };
188
191
  }
189
192
  interface SerializedCoverageConfig {
190
193
  provider: 'istanbul' | 'v8' | 'custom' | undefined;
@@ -68,7 +68,7 @@ function createCustomConsole(defaultState) {
68
68
  sendLog(type, taskId, content, buffer.length);
69
69
  }
70
70
  const timer = timers.get(taskId);
71
- buffers.set(taskId, []);
71
+ buffers.delete(taskId);
72
72
  if (type === "stderr") {
73
73
  timer.stderrTime = 0;
74
74
  } else {
@@ -1,7 +1,7 @@
1
1
  import { resolve, dirname, relative } from 'node:path';
2
2
  import { existsSync, writeFileSync, readFileSync } from 'node:fs';
3
3
  import { mkdir, writeFile } from 'node:fs/promises';
4
- import { p as prompt, f as findUp } from './index.Bn75ITYg.js';
4
+ import { p as prompt, f as findUp } from './index.X0nbfr6-.js';
5
5
  import c from 'tinyrainbow';
6
6
  import { detectPackageManager, installPackage } from './index.CPD77dLA.js';
7
7
  import { x } from 'tinyexec';
@@ -323,7 +323,7 @@ function getFrameworkTestPackage(framework) {
323
323
  case "preact":
324
324
  return "@testing-library/preact";
325
325
  case "solid":
326
- return "solid-testing-library";
326
+ return "@solidjs/testing-library";
327
327
  case "marko":
328
328
  return "@marko/testing-library";
329
329
  }
@@ -446,11 +446,8 @@ async function generateWorkspaceFile(options) {
446
446
  `import { defineWorkspace } from 'vitest/config'`,
447
447
  "",
448
448
  "export default defineWorkspace([",
449
- " // This will keep running your existing tests.",
450
- " // If you don't need to run those in Node.js anymore,",
451
- " // You can safely remove it from the workspace file",
452
- " // Or move the browser test configuration to the config file.",
453
- ` '${relativeRoot}',`,
449
+ " // If you want to keep running your existing tests in Node.js, uncomment the next line.",
450
+ ` // '${relativeRoot}',`,
454
451
  ` {`,
455
452
  ` extends: '${relativeRoot}',`,
456
453
  ` test: {`,
@@ -17,6 +17,7 @@ interface ModuleCache {
17
17
  }
18
18
  interface AfterSuiteRunMeta {
19
19
  coverage?: unknown;
20
+ testFiles: string[];
20
21
  transformMode: TransformMode | 'browser';
21
22
  projectName?: string;
22
23
  }
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from './constants.fzPh7AOq.js';
2
- import { V as VitestIndex } from './index.iyKRMe3s.js';
2
+ import { V as VitestIndex } from './index.-d_XpZEA.js';
3
3
  import '@vitest/runner';
4
4
  import './benchmark.C8CRJYG4.js';
5
5
  import '@vitest/runner/utils';
@@ -10,7 +10,7 @@ import './utils.Ck2hJTRs.js';
10
10
  import './env.CmHVDJnw.js';
11
11
  import 'std-env';
12
12
  import './run-once.Sxe67Wng.js';
13
- import './vi.D6IHiKAI.js';
13
+ import './vi.BskyZC5g.js';
14
14
  import 'chai';
15
15
  import './_commonjsHelpers.BFTU3MAI.js';
16
16
  import '@vitest/expect';
@@ -18,7 +18,7 @@ import '@vitest/snapshot';
18
18
  import '@vitest/utils/error';
19
19
  import './tasks.BZnCS9aT.js';
20
20
  import '@vitest/utils/source-map';
21
- import './base.BlXpj3e_.js';
21
+ import './base.DwXGwWst.js';
22
22
  import './date.W2xKR2qe.js';
23
23
  import '@vitest/spy';
24
24
 
@@ -0,0 +1,140 @@
1
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
+ import { b as bench } from './benchmark.C8CRJYG4.js';
3
+ import { i as isFirstRun, a as runOnce } from './run-once.Sxe67Wng.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.BskyZC5g.js';
5
+ import { g as getWorkerState } from './utils.Ck2hJTRs.js';
6
+ import * as chai from 'chai';
7
+ import { assert, should } from 'chai';
8
+
9
+ var dist = {};
10
+
11
+ var hasRequiredDist;
12
+
13
+ function requireDist () {
14
+ if (hasRequiredDist) return dist;
15
+ hasRequiredDist = 1;
16
+ (function (exports) {
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.expectTypeOf = void 0;
19
+ const fn = () => true;
20
+ /**
21
+ * Similar to Jest's `expect`, but with type-awareness.
22
+ * Gives you access to a number of type-matchers that let you make assertions about the
23
+ * form of a reference or generic type parameter.
24
+ *
25
+ * @example
26
+ * import {foo, bar} from '../foo'
27
+ * import {expectTypeOf} from 'expect-type'
28
+ *
29
+ * test('foo types', () => {
30
+ * // make sure `foo` has type {a: number}
31
+ * expectTypeOf(foo).toMatchTypeOf({a: 1})
32
+ * expectTypeOf(foo).toHaveProperty('a').toBeNumber()
33
+ *
34
+ * // make sure `bar` is a function taking a string:
35
+ * expectTypeOf(bar).parameter(0).toBeString()
36
+ * expectTypeOf(bar).returns.not.toBeAny()
37
+ * })
38
+ *
39
+ * @description
40
+ * See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.
41
+ */
42
+ const expectTypeOf = (_actual) => {
43
+ const nonFunctionProperties = [
44
+ 'parameters',
45
+ 'returns',
46
+ 'resolves',
47
+ 'not',
48
+ 'items',
49
+ 'constructorParameters',
50
+ 'thisParameter',
51
+ 'instance',
52
+ 'guards',
53
+ 'asserts',
54
+ 'branded',
55
+ ];
56
+ const obj = {
57
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
58
+ toBeAny: fn,
59
+ toBeUnknown: fn,
60
+ toBeNever: fn,
61
+ toBeFunction: fn,
62
+ toBeObject: fn,
63
+ toBeArray: fn,
64
+ toBeString: fn,
65
+ toBeNumber: fn,
66
+ toBeBoolean: fn,
67
+ toBeVoid: fn,
68
+ toBeSymbol: fn,
69
+ toBeNull: fn,
70
+ toBeUndefined: fn,
71
+ toBeNullable: fn,
72
+ toMatchTypeOf: fn,
73
+ toEqualTypeOf: fn,
74
+ toBeCallableWith: fn,
75
+ toBeConstructibleWith: fn,
76
+ /* eslint-enable @typescript-eslint/no-unsafe-assignment */
77
+ extract: exports.expectTypeOf,
78
+ exclude: exports.expectTypeOf,
79
+ pick: exports.expectTypeOf,
80
+ omit: exports.expectTypeOf,
81
+ toHaveProperty: exports.expectTypeOf,
82
+ parameter: exports.expectTypeOf,
83
+ };
84
+ const getterProperties = nonFunctionProperties;
85
+ getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
86
+ return obj;
87
+ };
88
+ exports.expectTypeOf = expectTypeOf;
89
+ } (dist));
90
+ return dist;
91
+ }
92
+
93
+ var distExports = requireDist();
94
+
95
+ function noop() {
96
+ }
97
+ const assertType = noop;
98
+
99
+ function getRunningMode() {
100
+ return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
101
+ }
102
+ function isWatchMode() {
103
+ return getRunningMode() === "watch";
104
+ }
105
+
106
+ function inject(key) {
107
+ const workerState = getWorkerState();
108
+ return workerState.providedContext[key];
109
+ }
110
+
111
+ var VitestIndex = /*#__PURE__*/Object.freeze({
112
+ __proto__: null,
113
+ afterAll: afterAll,
114
+ afterEach: afterEach,
115
+ assert: assert,
116
+ assertType: assertType,
117
+ beforeAll: beforeAll,
118
+ beforeEach: beforeEach,
119
+ bench: bench,
120
+ chai: chai,
121
+ createExpect: createExpect,
122
+ describe: describe,
123
+ expect: globalExpect,
124
+ expectTypeOf: distExports.expectTypeOf,
125
+ getRunningMode: getRunningMode,
126
+ inject: inject,
127
+ isFirstRun: isFirstRun,
128
+ isWatchMode: isWatchMode,
129
+ it: it,
130
+ onTestFailed: onTestFailed,
131
+ onTestFinished: onTestFinished,
132
+ runOnce: runOnce,
133
+ should: should,
134
+ suite: suite,
135
+ test: test,
136
+ vi: vi,
137
+ vitest: vitest
138
+ });
139
+
140
+ export { VitestIndex as V, assertType as a, inject as b, distExports as d, getRunningMode as g, isWatchMode as i };
@@ -4,7 +4,7 @@ import { distDir } from '../path.js';
4
4
  import { g as getWorkerState } from './utils.Ck2hJTRs.js';
5
5
  import { r as rpc } from './rpc.B7Mfb-Yf.js';
6
6
  import { t as takeCoverageInsideWorker } from './coverage.zlNdAMHK.js';
7
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.DV1PI68g.js';
7
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BKyF15v_.js';
8
8
 
9
9
  function setupChaiConfig(config) {
10
10
  Object.assign(chai.config, config);
@@ -82,6 +82,7 @@ async function resolveTestRunner(config, executor) {
82
82
  if (coverage) {
83
83
  rpc().onAfterSuiteRun({
84
84
  coverage,
85
+ testFiles: files.map((file) => file.name).sort(),
85
86
  transformMode: state.environment.transformMode,
86
87
  projectName: state.ctx.projectName
87
88
  });