vitest 2.2.0-beta.2 → 3.0.0-beta.2

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 (54) hide show
  1. package/LICENSE.md +75 -0
  2. package/dist/browser.d.ts +13 -10
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{RandomSequencer.BPedXEug.js → RandomSequencer.gisBJ77r.js} +11 -4
  5. package/dist/chunks/{base.BS0HhLXd.js → base.CUgXReRN.js} +8 -3
  6. package/dist/chunks/{cac.Cs06pOqp.js → cac.Xzv7eNWw.js} +22 -17
  7. package/dist/chunks/{cli-api.CB-jIbYQ.js → cli-api.CETCDGgZ.js} +985 -498
  8. package/dist/chunks/{config.CPguQ7J1.d.ts → config.BTPBhmK5.d.ts} +1 -1
  9. package/dist/chunks/{coverage.BoMDb1ip.js → coverage.BWeNbfBa.js} +4 -4
  10. package/dist/chunks/{creator.IIqd8RWT.js → creator.DcAcUhMD.js} +1 -4
  11. package/dist/chunks/{environment.CT0jpO-1.d.ts → environment.d8YfPkTm.d.ts} +1 -3
  12. package/dist/chunks/{globals.BCGEw6ON.js → globals.BFncSRNA.js} +2 -2
  13. package/dist/chunks/{index.bzFpKeaq.js → index.9ZEBV_TJ.js} +992 -577
  14. package/dist/chunks/{index.DD5eTY2y.js → index.CkWmZCXU.js} +1 -1
  15. package/dist/chunks/{index.CqYx2Nsr.js → index.DQboAxJm.js} +23 -14
  16. package/dist/chunks/{index.BjjsHdBb.js → index.DoV7W5gc.js} +2 -2
  17. package/dist/chunks/{inspector.70d6emsh.js → inspector.DKLceBVD.js} +1 -1
  18. package/dist/chunks/{reporters.F9D2idOT.d.ts → reporters.DTtxC3KQ.d.ts} +588 -524
  19. package/dist/chunks/{resolveConfig.CLnvCvEs.js → resolveConfig.BA-_OKEx.js} +5599 -5570
  20. package/dist/chunks/{runBaseTests.B7hcVT-s.js → runBaseTests.D0dWpzZV.js} +13 -12
  21. package/dist/chunks/{setup-common.BfGt8K-K.js → setup-common.Cp_bu5q3.js} +1 -1
  22. package/dist/chunks/types.BOjykUpq.d.ts +27 -0
  23. package/dist/chunks/{utils.DJONn5B5.js → utils.CMUTX-p8.js} +5 -2
  24. package/dist/chunks/{vi.BlPttogV.js → vi.S4Fq8wSo.js} +20 -14
  25. package/dist/chunks/{vite.DonA4fvH.d.ts → vite.CXaetSK3.d.ts} +1 -1
  26. package/dist/chunks/{vm.Zr4qWzDJ.js → vm.DGhTouO3.js} +10 -1
  27. package/dist/chunks/{worker.Qz1UB4Fv.d.ts → worker.ClntunZp.d.ts} +1 -1
  28. package/dist/chunks/{worker.9VY11NZs.d.ts → worker.o1PBoDdo.d.ts} +4 -4
  29. package/dist/cli.js +1 -1
  30. package/dist/config.cjs +1 -10
  31. package/dist/config.d.ts +7 -10
  32. package/dist/config.js +1 -10
  33. package/dist/coverage.d.ts +5 -7
  34. package/dist/coverage.js +4 -4
  35. package/dist/environments.d.ts +2 -2
  36. package/dist/execute.d.ts +4 -4
  37. package/dist/index.d.ts +27 -22
  38. package/dist/index.js +2 -2
  39. package/dist/node.d.ts +25 -33
  40. package/dist/node.js +66 -32
  41. package/dist/reporters.d.ts +5 -7
  42. package/dist/reporters.js +5 -4
  43. package/dist/runners.d.ts +3 -4
  44. package/dist/runners.js +9 -14
  45. package/dist/suite.d.ts +1 -1
  46. package/dist/worker.js +1 -1
  47. package/dist/workers/forks.js +1 -1
  48. package/dist/workers/runVmTests.js +9 -9
  49. package/dist/workers/threads.js +1 -1
  50. package/dist/workers/vmForks.js +1 -1
  51. package/dist/workers/vmThreads.js +1 -1
  52. package/dist/workers.d.ts +4 -4
  53. package/dist/workers.js +3 -3
  54. package/package.json +23 -24
@@ -1,4 +1,4 @@
1
- import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.BlPttogV.js';
1
+ import { c as createExpect, a as globalExpect, i as inject, v as vi, b as vitest } from './vi.S4Fq8wSo.js';
2
2
  import { i as isFirstRun, a as runOnce } from './run-once.2ogXb3JV.js';
3
3
  import { b as bench } from './benchmark.Cdu9hjj4.js';
4
4
  import { expectTypeOf } from 'expect-type';
@@ -1,10 +1,7 @@
1
- import process$1 from 'process';
2
- import fs from 'node:fs';
3
- import fsp from 'node:fs/promises';
4
- import a from 'node:path';
5
1
  import process from 'node:process';
6
- import { existsSync } from 'fs';
7
- import { resolve } from 'path';
2
+ import fs, { existsSync } from 'node:fs';
3
+ import fsp from 'node:fs/promises';
4
+ import a, { resolve } from 'node:path';
8
5
  import { x } from 'tinyexec';
9
6
 
10
7
  const AGENTS = [
@@ -13,17 +10,20 @@ const AGENTS = [
13
10
  "yarn@berry",
14
11
  "pnpm",
15
12
  "pnpm@6",
16
- "bun"
13
+ "bun",
14
+ "deno"
17
15
  ];
18
16
  const LOCKS = {
19
17
  "bun.lockb": "bun",
18
+ "deno.lock": "deno",
20
19
  "pnpm-lock.yaml": "pnpm",
21
20
  "yarn.lock": "yarn",
22
21
  "package-lock.json": "npm",
23
22
  "npm-shrinkwrap.json": "npm"
24
23
  };
25
24
 
26
- async function detect({ cwd, onUnknown } = {}) {
25
+ async function detect(options = {}) {
26
+ const { cwd, onUnknown } = options;
27
27
  for (const directory of lookup(cwd)) {
28
28
  for (const lock of Object.keys(LOCKS)) {
29
29
  if (await fileExists(a.join(directory, lock))) {
@@ -50,8 +50,9 @@ function* lookup(cwd = process.cwd()) {
50
50
  }
51
51
  }
52
52
  async function parsePackageJson(filepath, onUnknown) {
53
- if (!filepath || !await fileExists(filepath))
54
- return null;
53
+ return !filepath || !await fileExists(filepath) ? null : handlePackageManager(filepath, onUnknown);
54
+ }
55
+ function handlePackageManager(filepath, onUnknown) {
55
56
  try {
56
57
  const pkg = JSON.parse(fs.readFileSync(filepath, "utf8"));
57
58
  let agent;
@@ -88,7 +89,7 @@ async function fileExists(filePath) {
88
89
  }
89
90
 
90
91
  // src/detect.ts
91
- async function detectPackageManager(cwd = process$1.cwd()) {
92
+ async function detectPackageManager(cwd = process.cwd()) {
92
93
  const result = await detect({
93
94
  cwd,
94
95
  onUnknown(packageManager) {
@@ -103,15 +104,23 @@ async function installPackage(names, options = {}) {
103
104
  const [agent] = detectedAgent.split("@");
104
105
  if (!Array.isArray(names))
105
106
  names = [names];
106
- const args = options.additionalArgs || [];
107
+ const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
107
108
  if (options.preferOffline) {
108
109
  if (detectedAgent === "yarn@berry")
109
110
  args.unshift("--cached");
110
111
  else
111
112
  args.unshift("--prefer-offline");
112
113
  }
113
- if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process$1.cwd(), "pnpm-workspace.yaml")))
114
- args.unshift("-w");
114
+ if (agent === "pnpm" && existsSync(resolve(options.cwd ?? process.cwd(), "pnpm-workspace.yaml"))) {
115
+ args.unshift(
116
+ "-w",
117
+ /**
118
+ * Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
119
+ * @see https://pnpm.io/cli/install#--prod--p
120
+ */
121
+ "--prod=false"
122
+ );
123
+ }
115
124
  return x(
116
125
  agent,
117
126
  [
@@ -1,9 +1,9 @@
1
1
  import * as chai from 'chai';
2
2
  import { resolve } from 'node:path';
3
- import { t as takeCoverageInsideWorker } from './coverage.BoMDb1ip.js';
3
+ import { t as takeCoverageInsideWorker } from './coverage.BWeNbfBa.js';
4
4
  import { distDir } from '../path.js';
5
5
  import { r as rpc } from './rpc.C3q9uwRX.js';
6
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.BfGt8K-K.js';
6
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.Cp_bu5q3.js';
7
7
  import { g as getWorkerState } from './utils.C8RiOc4B.js';
8
8
 
9
9
  function setupChaiConfig(config) {
@@ -17,7 +17,7 @@ function setupInspect(ctx) {
17
17
  config.inspector.waitForDebugger
18
18
  );
19
19
  if (config.inspectBrk) {
20
- const firstTestFile = ctx.files[0];
20
+ const firstTestFile = typeof ctx.files[0] === "string" ? ctx.files[0] : ctx.files[0].filepath;
21
21
  if (firstTestFile) {
22
22
  session = new inspector.Session();
23
23
  session.connect();