vitest 1.4.0 → 1.5.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 (44) hide show
  1. package/dist/browser.d.ts +4 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{integrations-globals.trMeEBob.js → integrations-globals.2J_Aii2q.js} +3 -3
  4. package/dist/chunks/{runtime-console.tUKE_2UJ.js → runtime-console.kbFEN7E-.js} +14 -6
  5. package/dist/chunks/{runtime-runBaseTests.SKlFOhuq.js → runtime-runBaseTests.3fVSWBsC.js} +11 -9
  6. package/dist/cli-wrapper.js +1 -1
  7. package/dist/cli.js +6 -6
  8. package/dist/config.cjs +1 -0
  9. package/dist/config.d.ts +1 -1
  10. package/dist/config.js +1 -0
  11. package/dist/coverage.d.ts +1 -1
  12. package/dist/environments.d.ts +1 -1
  13. package/dist/execute.d.ts +1 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +3 -3
  16. package/dist/node.d.ts +2 -2
  17. package/dist/node.js +6 -6
  18. package/dist/{reporters-P7C2ytIv.d.ts → reporters-LqC_WI4d.d.ts} +36 -8
  19. package/dist/reporters.d.ts +1 -1
  20. package/dist/reporters.js +3 -3
  21. package/dist/runners.d.ts +1 -1
  22. package/dist/runners.js +3 -3
  23. package/dist/{suite-a18diDsI.d.ts → suite-ynYMzeLu.d.ts} +1 -1
  24. package/dist/suite.d.ts +2 -2
  25. package/dist/vendor/{base.nhvUBzQY.js → base.BjeeYg4o.js} +1 -1
  26. package/dist/vendor/{cac.RvTIWZBK.js → cac.qnW6GNL2.js} +156 -74
  27. package/dist/vendor/{constants.K-Wf1PUy.js → constants.5J7I254_.js} +2 -1
  28. package/dist/vendor/{index.LNWuEnUT.js → index.-ITFwqG_.js} +1 -1
  29. package/dist/vendor/{index.BeX1oZht.js → index.12jbrDSD.js} +1 -1
  30. package/dist/vendor/{index.e9RDLAeW.js → index.kSaPvGW6.js} +32 -7
  31. package/dist/vendor/inspector.IgLX3ur5.js +54 -0
  32. package/dist/vendor/{setup-common.vyF1kALR.js → setup-common.A1De6efh.js} +8 -1
  33. package/dist/vendor/{utils.w0xgzP1h.js → utils.0uYuCbzo.js} +5 -2
  34. package/dist/vendor/{vi.JYQecGiw.js → vi.Fxjax7rQ.js} +21 -20
  35. package/dist/vendor/{vm.cAHVDF92.js → vm.I_IsyNig.js} +2 -2
  36. package/dist/worker.js +2 -39
  37. package/dist/workers/forks.js +2 -2
  38. package/dist/workers/runVmTests.js +10 -4
  39. package/dist/workers/threads.js +2 -2
  40. package/dist/workers/vmForks.js +7 -7
  41. package/dist/workers/vmThreads.js +7 -7
  42. package/dist/workers.d.ts +1 -1
  43. package/dist/workers.js +8 -7
  44. package/package.json +11 -11
@@ -1,9 +1,9 @@
1
- import { dirname, resolve, relative, normalize, join, basename, toNamespacedPath } from 'pathe';
1
+ import { dirname, resolve, relative, normalize, join, basename, toNamespacedPath, isAbsolute } from 'pathe';
2
2
  import require$$0$3, { EventEmitter as EventEmitter$2 } from 'events';
3
3
  import c from 'picocolors';
4
4
  import { b as removeUndefinedValues, c as isWindows } from './index.ir9i0ywP.js';
5
- import { w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as generateCodeFrame, i as highlightCode, j as divider, L as Logger, s as stripAnsi } from './index.e9RDLAeW.js';
6
- import { A as API_PATH, c as configFiles, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES } from './constants.K-Wf1PUy.js';
5
+ import { w as wrapSerializableConfig, f as Typechecker, R as ReportersMap, e as BenchmarkReportsMap, g as RandomSequencer, B as BaseSequencer, h as generateCodeFrame, i as highlightCode, j as divider, L as Logger, s as stripAnsi } from './index.kSaPvGW6.js';
6
+ import { A as API_PATH, c as configFiles, d as defaultPort, e as extraInlineDeps, a as defaultBrowserPort, b as defaultInspectPort, E as EXIT_CODE_RESTART, w as workspacesFiles, C as CONFIG_NAMES } from './constants.5J7I254_.js';
7
7
  import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.E7sG1b3r.js';
8
8
  import { g as getEnvPackageName } from './index.GVFv9dZ0.js';
9
9
  import { isFileServingAllowed, loadConfigFromFile, searchForWorkspaceRoot, version as version$1, createServer, mergeConfig } from 'vite';
@@ -11,6 +11,7 @@ import path$8 from 'node:path';
11
11
  import url, { fileURLToPath } from 'node:url';
12
12
  import process$1 from 'node:process';
13
13
  import fs$8, { promises, existsSync } from 'node:fs';
14
+ import { MessageChannel, isMainThread } from 'node:worker_threads';
14
15
  import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.jjO7Zipk.js';
15
16
  import require$$0 from 'os';
16
17
  import p from 'path';
@@ -38,7 +39,6 @@ import * as nodeos from 'node:os';
38
39
  import nodeos__default from 'node:os';
39
40
  import EventEmitter$3 from 'node:events';
40
41
  import Tinypool$1, { Tinypool } from 'tinypool';
41
- import { MessageChannel } from 'node:worker_threads';
42
42
  import { hasFailed, getTests } from '@vitest/runner/utils';
43
43
  import { resolveModule, isPackageExists } from 'local-pkg';
44
44
  import { isCI, provider as provider$1 } from 'std-env';
@@ -728,7 +728,7 @@ class CAC extends EventEmitter$2 {
728
728
 
729
729
  const cac = (name = "") => new CAC(name);
730
730
 
731
- var version = "1.4.0";
731
+ var version = "1.5.0";
732
732
 
733
733
  /*
734
734
  How it works:
@@ -9695,6 +9695,7 @@ const coverageConfigDefaults = {
9695
9695
  reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
9696
9696
  extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte", ".marko"],
9697
9697
  allowExternal: false,
9698
+ ignoreEmptyLines: false,
9698
9699
  processingConcurrency: Math.min(20, ((_b = (_a = nodeos__default).availableParallelism) == null ? void 0 : _b.call(_a)) ?? nodeos__default.cpus().length)
9699
9700
  };
9700
9701
  const fakeTimersDefaults = {
@@ -9887,6 +9888,18 @@ function resolvePath(path, root) {
9887
9888
  resolveModule(path, { paths: [root] }) ?? resolve(root, path)
9888
9889
  );
9889
9890
  }
9891
+ function parseInspector(inspect) {
9892
+ if (typeof inspect === "boolean" || inspect === void 0)
9893
+ return {};
9894
+ if (typeof inspect === "number")
9895
+ return { port: inspect };
9896
+ if (inspect.match(/https?:\//))
9897
+ throw new Error(`Inspector host cannot be a URL. Use "host:port" instead of "${inspect}"`);
9898
+ const [host, port] = inspect.split(":");
9899
+ if (!port)
9900
+ return { host };
9901
+ return { host, port: Number(port) || defaultInspectPort };
9902
+ }
9890
9903
  function resolveApiServerConfig(options) {
9891
9904
  let api;
9892
9905
  if (options.ui && !options.api)
@@ -9916,7 +9929,7 @@ function resolveApiServerConfig(options) {
9916
9929
  return api;
9917
9930
  }
9918
9931
  function resolveConfig(mode, options, viteConfig) {
9919
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
9932
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
9920
9933
  if (options.dom) {
9921
9934
  if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
9922
9935
  console.warn(
@@ -9933,8 +9946,13 @@ function resolveConfig(mode, options, viteConfig) {
9933
9946
  root: viteConfig.root,
9934
9947
  mode
9935
9948
  };
9936
- resolved.inspect = Boolean(resolved.inspect);
9937
- resolved.inspectBrk = Boolean(resolved.inspectBrk);
9949
+ const inspector = resolved.inspect || resolved.inspectBrk;
9950
+ resolved.inspector = {
9951
+ ...resolved.inspector,
9952
+ ...parseInspector(inspector),
9953
+ enabled: !!inspector,
9954
+ waitForDebugger: ((_b = options.inspector) == null ? void 0 : _b.waitForDebugger) ?? !!resolved.inspectBrk
9955
+ };
9938
9956
  if (viteConfig.base !== "/")
9939
9957
  resolved.base = viteConfig.base;
9940
9958
  resolved.clearScreen = resolved.clearScreen ?? viteConfig.clearScreen ?? true;
@@ -9954,14 +9972,14 @@ function resolveConfig(mode, options, viteConfig) {
9954
9972
  resolved.maxWorkers = Number(resolved.maxWorkers);
9955
9973
  if (resolved.minWorkers)
9956
9974
  resolved.minWorkers = Number(resolved.minWorkers);
9957
- resolved.fileParallelism ?? (resolved.fileParallelism = true);
9975
+ resolved.fileParallelism ?? (resolved.fileParallelism = mode !== "benchmark");
9958
9976
  if (!resolved.fileParallelism) {
9959
9977
  resolved.maxWorkers = 1;
9960
9978
  resolved.minWorkers = 1;
9961
9979
  }
9962
9980
  if (resolved.inspect || resolved.inspectBrk) {
9963
- const isSingleThread = resolved.pool === "threads" && ((_c = (_b = resolved.poolOptions) == null ? void 0 : _b.threads) == null ? void 0 : _c.singleThread);
9964
- const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
9981
+ const isSingleThread = resolved.pool === "threads" && ((_d = (_c = resolved.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.singleThread);
9982
+ const isSingleFork = resolved.pool === "forks" && ((_f = (_e = resolved.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.singleFork);
9965
9983
  if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
9966
9984
  const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
9967
9985
  throw new Error(`You cannot use ${inspectOption} without "--no-file-parallelism", "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
@@ -9977,7 +9995,7 @@ function resolveConfig(mode, options, viteConfig) {
9977
9995
  throw new Error(`You cannot set "coverage.reportsDirectory" as ${reportsDirectory}. Vitest needs to be able to remove this directory before test run`);
9978
9996
  }
9979
9997
  resolved.deps ?? (resolved.deps = {});
9980
- (_f = resolved.deps).moduleDirectories ?? (_f.moduleDirectories = []);
9998
+ (_g = resolved.deps).moduleDirectories ?? (_g.moduleDirectories = []);
9981
9999
  resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map((dir) => {
9982
10000
  if (!dir.startsWith("/"))
9983
10001
  dir = `/${dir}`;
@@ -9987,17 +10005,17 @@ function resolveConfig(mode, options, viteConfig) {
9987
10005
  });
9988
10006
  if (!resolved.deps.moduleDirectories.includes("/node_modules/"))
9989
10007
  resolved.deps.moduleDirectories.push("/node_modules/");
9990
- (_g = resolved.deps).optimizer ?? (_g.optimizer = {});
9991
- (_h = resolved.deps.optimizer).ssr ?? (_h.ssr = {});
9992
- (_i = resolved.deps.optimizer.ssr).enabled ?? (_i.enabled = true);
9993
- (_j = resolved.deps.optimizer).web ?? (_j.web = {});
9994
- (_k = resolved.deps.optimizer.web).enabled ?? (_k.enabled = true);
9995
- (_l = resolved.deps).web ?? (_l.web = {});
9996
- (_m = resolved.deps.web).transformAssets ?? (_m.transformAssets = true);
9997
- (_n = resolved.deps.web).transformCss ?? (_n.transformCss = true);
9998
- (_o = resolved.deps.web).transformGlobPattern ?? (_o.transformGlobPattern = []);
10008
+ (_h = resolved.deps).optimizer ?? (_h.optimizer = {});
10009
+ (_i = resolved.deps.optimizer).ssr ?? (_i.ssr = {});
10010
+ (_j = resolved.deps.optimizer.ssr).enabled ?? (_j.enabled = true);
10011
+ (_k = resolved.deps.optimizer).web ?? (_k.web = {});
10012
+ (_l = resolved.deps.optimizer.web).enabled ?? (_l.enabled = true);
10013
+ (_m = resolved.deps).web ?? (_m.web = {});
10014
+ (_n = resolved.deps.web).transformAssets ?? (_n.transformAssets = true);
10015
+ (_o = resolved.deps.web).transformCss ?? (_o.transformCss = true);
10016
+ (_p = resolved.deps.web).transformGlobPattern ?? (_p.transformGlobPattern = []);
9999
10017
  resolved.server ?? (resolved.server = {});
10000
- (_p = resolved.server).deps ?? (_p.deps = {});
10018
+ (_q = resolved.server).deps ?? (_q.deps = {});
10001
10019
  const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
10002
10020
  deprecatedDepsOptions.forEach((option) => {
10003
10021
  if (resolved.deps[option] === void 0)
@@ -10022,11 +10040,11 @@ function resolveConfig(mode, options, viteConfig) {
10022
10040
  if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
10023
10041
  resolved.server.deps.inline = true;
10024
10042
  } else {
10025
- (_q = resolved.server.deps).inline ?? (_q.inline = []);
10043
+ (_r = resolved.server.deps).inline ?? (_r.inline = []);
10026
10044
  resolved.server.deps.inline.push(...extraInlineDeps);
10027
10045
  }
10028
10046
  }
10029
- (_r = resolved.server.deps).moduleDirectories ?? (_r.moduleDirectories = []);
10047
+ (_s = resolved.server.deps).moduleDirectories ?? (_s.moduleDirectories = []);
10030
10048
  resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
10031
10049
  if (resolved.runner)
10032
10050
  resolved.runner = resolvePath(resolved.runner, resolved.root);
@@ -10054,11 +10072,11 @@ function resolveConfig(mode, options, viteConfig) {
10054
10072
  resolved.poolOptions = {
10055
10073
  ...resolved.poolOptions,
10056
10074
  threads: {
10057
- ...(_s = resolved.poolOptions) == null ? void 0 : _s.threads,
10075
+ ...(_t = resolved.poolOptions) == null ? void 0 : _t.threads,
10058
10076
  maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
10059
10077
  },
10060
10078
  vmThreads: {
10061
- ...(_t = resolved.poolOptions) == null ? void 0 : _t.vmThreads,
10079
+ ...(_u = resolved.poolOptions) == null ? void 0 : _u.vmThreads,
10062
10080
  maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
10063
10081
  }
10064
10082
  };
@@ -10067,11 +10085,11 @@ function resolveConfig(mode, options, viteConfig) {
10067
10085
  resolved.poolOptions = {
10068
10086
  ...resolved.poolOptions,
10069
10087
  threads: {
10070
- ...(_u = resolved.poolOptions) == null ? void 0 : _u.threads,
10088
+ ...(_v = resolved.poolOptions) == null ? void 0 : _v.threads,
10071
10089
  minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
10072
10090
  },
10073
10091
  vmThreads: {
10074
- ...(_v = resolved.poolOptions) == null ? void 0 : _v.vmThreads,
10092
+ ...(_w = resolved.poolOptions) == null ? void 0 : _w.vmThreads,
10075
10093
  minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
10076
10094
  }
10077
10095
  };
@@ -10080,11 +10098,11 @@ function resolveConfig(mode, options, viteConfig) {
10080
10098
  resolved.poolOptions = {
10081
10099
  ...resolved.poolOptions,
10082
10100
  forks: {
10083
- ...(_w = resolved.poolOptions) == null ? void 0 : _w.forks,
10101
+ ...(_x = resolved.poolOptions) == null ? void 0 : _x.forks,
10084
10102
  maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
10085
10103
  },
10086
10104
  vmForks: {
10087
- ...(_x = resolved.poolOptions) == null ? void 0 : _x.vmForks,
10105
+ ...(_y = resolved.poolOptions) == null ? void 0 : _y.vmForks,
10088
10106
  maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
10089
10107
  }
10090
10108
  };
@@ -10093,11 +10111,11 @@ function resolveConfig(mode, options, viteConfig) {
10093
10111
  resolved.poolOptions = {
10094
10112
  ...resolved.poolOptions,
10095
10113
  forks: {
10096
- ...(_y = resolved.poolOptions) == null ? void 0 : _y.forks,
10114
+ ...(_z = resolved.poolOptions) == null ? void 0 : _z.forks,
10097
10115
  minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
10098
10116
  },
10099
10117
  vmForks: {
10100
- ...(_z = resolved.poolOptions) == null ? void 0 : _z.vmForks,
10118
+ ...(_A = resolved.poolOptions) == null ? void 0 : _A.vmForks,
10101
10119
  minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
10102
10120
  }
10103
10121
  };
@@ -10189,8 +10207,8 @@ function resolveConfig(mode, options, viteConfig) {
10189
10207
  resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
10190
10208
  resolved.css ?? (resolved.css = {});
10191
10209
  if (typeof resolved.css === "object") {
10192
- (_A = resolved.css).modules ?? (_A.modules = {});
10193
- (_B = resolved.css.modules).classNameStrategy ?? (_B.classNameStrategy = "stable");
10210
+ (_B = resolved.css).modules ?? (_B.modules = {});
10211
+ (_C = resolved.css.modules).classNameStrategy ?? (_C.classNameStrategy = "stable");
10194
10212
  }
10195
10213
  if (resolved.cache !== false) {
10196
10214
  let cacheDir = VitestCache.resolveCacheDir("", resolve(viteConfig.cacheDir, "vitest"), resolved.name);
@@ -10207,29 +10225,29 @@ function resolveConfig(mode, options, viteConfig) {
10207
10225
  resolved.sequence ?? (resolved.sequence = {});
10208
10226
  if (resolved.sequence.shuffle && typeof resolved.sequence.shuffle === "object") {
10209
10227
  const { files, tests } = resolved.sequence.shuffle;
10210
- (_C = resolved.sequence).sequencer ?? (_C.sequencer = files ? RandomSequencer : BaseSequencer);
10228
+ (_D = resolved.sequence).sequencer ?? (_D.sequencer = files ? RandomSequencer : BaseSequencer);
10211
10229
  resolved.sequence.shuffle = tests;
10212
10230
  }
10213
- if (!((_D = resolved.sequence) == null ? void 0 : _D.sequencer)) {
10231
+ if (!((_E = resolved.sequence) == null ? void 0 : _E.sequencer)) {
10214
10232
  resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
10215
10233
  }
10216
- (_E = resolved.sequence).hooks ?? (_E.hooks = "parallel");
10234
+ (_F = resolved.sequence).hooks ?? (_F.hooks = "parallel");
10217
10235
  if (resolved.sequence.sequencer === RandomSequencer)
10218
- (_F = resolved.sequence).seed ?? (_F.seed = Date.now());
10236
+ (_G = resolved.sequence).seed ?? (_G.seed = Date.now());
10219
10237
  resolved.typecheck = {
10220
10238
  ...configDefaults.typecheck,
10221
10239
  ...resolved.typecheck
10222
10240
  };
10223
10241
  resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve(resolved.root, i[0]), i[1]]);
10224
10242
  resolved.typecheck ?? (resolved.typecheck = {});
10225
- (_G = resolved.typecheck).enabled ?? (_G.enabled = false);
10243
+ (_H = resolved.typecheck).enabled ?? (_H.enabled = false);
10226
10244
  if (resolved.typecheck.enabled)
10227
10245
  console.warn(c.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."));
10228
10246
  resolved.browser ?? (resolved.browser = {});
10229
- (_H = resolved.browser).enabled ?? (_H.enabled = false);
10230
- (_I = resolved.browser).headless ?? (_I.headless = isCI);
10231
- (_J = resolved.browser).slowHijackESM ?? (_J.slowHijackESM = false);
10232
- (_K = resolved.browser).isolate ?? (_K.isolate = true);
10247
+ (_I = resolved.browser).enabled ?? (_I.enabled = false);
10248
+ (_J = resolved.browser).headless ?? (_J.headless = isCI);
10249
+ (_K = resolved.browser).slowHijackESM ?? (_K.slowHijackESM = false);
10250
+ (_L = resolved.browser).isolate ?? (_L.isolate = true);
10233
10251
  if (resolved.browser.enabled && provider$1 === "stackblitz")
10234
10252
  resolved.browser.provider = "none";
10235
10253
  resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
@@ -10983,24 +11001,40 @@ async function loadGlobalSetupFile(file, runner) {
10983
11001
  }
10984
11002
 
10985
11003
  async function initializeProject(workspacePath, ctx, options) {
10986
- var _a;
10987
11004
  const project = new WorkspaceProject(workspacePath, ctx, options);
10988
11005
  const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
10989
11006
  const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
10990
- const config = {
10991
- ...options,
10992
- root,
10993
- logLevel: "error",
10994
- configFile,
10995
- // this will make "mode": "test" | "benchmark" inside defineConfig
10996
- mode: ((_a = options.test) == null ? void 0 : _a.mode) || options.mode || ctx.config.mode,
10997
- plugins: [
10998
- ...options.plugins || [],
10999
- WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
11000
- ]
11001
- };
11002
- await createViteServer(config);
11003
- return project;
11007
+ return new Promise((resolve2, reject) => {
11008
+ var _a;
11009
+ const resolution = createDefer();
11010
+ let configResolved = false;
11011
+ const config = {
11012
+ ...options,
11013
+ root,
11014
+ logLevel: "error",
11015
+ configFile,
11016
+ // this will make "mode": "test" | "benchmark" inside defineConfig
11017
+ mode: ((_a = options.test) == null ? void 0 : _a.mode) || options.mode || ctx.config.mode,
11018
+ plugins: [
11019
+ {
11020
+ name: "vitest:workspace:resolve",
11021
+ configResolved() {
11022
+ configResolved = true;
11023
+ resolve2(() => resolution);
11024
+ }
11025
+ },
11026
+ ...options.plugins || [],
11027
+ WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
11028
+ ]
11029
+ };
11030
+ createViteServer(config).then(() => resolution.resolve(project)).catch((err) => {
11031
+ if (configResolved)
11032
+ resolution.reject(err);
11033
+ else
11034
+ reject(err);
11035
+ });
11036
+ return project;
11037
+ });
11004
11038
  }
11005
11039
  class WorkspaceProject {
11006
11040
  constructor(path, ctx, options) {
@@ -11162,7 +11196,7 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
11162
11196
  isInSourceTestFile(code) {
11163
11197
  return code.includes("import.meta.vitest");
11164
11198
  }
11165
- filterFiles(testFiles, filters = [], dir) {
11199
+ filterFiles(testFiles, filters, dir) {
11166
11200
  if (filters.length && process.platform === "win32")
11167
11201
  filters = filters.map((f) => toNamespacedPath(f));
11168
11202
  if (filters.length) {
@@ -11170,6 +11204,10 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
11170
11204
  const testFile = relative(dir, t).toLocaleLowerCase();
11171
11205
  return filters.some((f) => {
11172
11206
  const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
11207
+ if (isAbsolute(f)) {
11208
+ if (relativePath === ".." || relativePath === "../" || relativePath.startsWith("../.."))
11209
+ return true;
11210
+ }
11173
11211
  return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
11174
11212
  });
11175
11213
  });
@@ -11224,7 +11262,7 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
11224
11262
  return isBrowserEnabled(this.config);
11225
11263
  }
11226
11264
  getSerializableConfig() {
11227
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
11265
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
11228
11266
  const optimizer = (_a = this.config.deps) == null ? void 0 : _a.optimizer;
11229
11267
  const poolOptions = this.config.poolOptions;
11230
11268
  const isolate = (_d = (_c = (_b = this.server) == null ? void 0 : _b.config) == null ? void 0 : _c.test) == null ? void 0 : _d.isolate;
@@ -11272,8 +11310,13 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
11272
11310
  },
11273
11311
  inspect: this.ctx.config.inspect,
11274
11312
  inspectBrk: this.ctx.config.inspectBrk,
11313
+ inspector: this.ctx.config.inspector,
11275
11314
  alias: [],
11276
- includeTaskLocation: this.config.includeTaskLocation ?? this.ctx.config.includeTaskLocation
11315
+ includeTaskLocation: this.config.includeTaskLocation ?? this.ctx.config.includeTaskLocation,
11316
+ env: {
11317
+ ...(_v = this.server) == null ? void 0 : _v.config.env,
11318
+ ...this.config.env
11319
+ }
11277
11320
  }, this.ctx.configOverride || {});
11278
11321
  }
11279
11322
  close() {
@@ -11562,17 +11605,37 @@ class Vitest {
11562
11605
  acc[name] = cliOptions[name];
11563
11606
  return acc;
11564
11607
  }, {});
11565
- const projects = filteredWorkspaces.map(async (workspacePath) => {
11566
- if (this.server.config.configFile === workspacePath)
11567
- return this.createCoreProject();
11568
- return initializeProject(workspacePath, this, { workspaceConfigPath, test: cliOverrides });
11569
- });
11608
+ const cwd = process.cwd();
11609
+ const projects = [];
11610
+ try {
11611
+ for (const filepath of filteredWorkspaces) {
11612
+ if (this.server.config.configFile === filepath) {
11613
+ const project = await this.createCoreProject();
11614
+ projects.push(() => Promise.resolve(project));
11615
+ continue;
11616
+ }
11617
+ const dir = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
11618
+ if (isMainThread)
11619
+ process.chdir(dir);
11620
+ projects.push(await initializeProject(filepath, this, { workspaceConfigPath, test: cliOverrides }));
11621
+ }
11622
+ } finally {
11623
+ if (isMainThread)
11624
+ process.chdir(cwd);
11625
+ }
11626
+ const projectPromises = [];
11570
11627
  projectsOptions.forEach((options, index) => {
11571
- projects.push(initializeProject(index, this, mergeConfig(options, { workspaceConfigPath, test: cliOverrides })));
11628
+ projectPromises.push(initializeProject(index, this, mergeConfig(options, { workspaceConfigPath, test: cliOverrides })));
11572
11629
  });
11573
- if (!projects.length)
11630
+ if (!projects.length && !projectPromises.length)
11574
11631
  return [await this.createCoreProject()];
11575
- const resolvedProjects = await Promise.all(projects);
11632
+ const resolvedProjectsReceivers = [
11633
+ ...projects,
11634
+ ...await Promise.all(projectPromises)
11635
+ ];
11636
+ const resolvedProjects = await Promise.all(
11637
+ resolvedProjectsReceivers.map((receiver) => receiver())
11638
+ );
11576
11639
  const names = /* @__PURE__ */ new Set();
11577
11640
  for (const project of resolvedProjects) {
11578
11641
  const name = project.getName();
@@ -11935,14 +11998,14 @@ class Vitest {
11935
11998
  if (!i.file)
11936
11999
  return;
11937
12000
  const heedsRerun = this.handleFileChanged(i.file);
11938
- if (heedsRerun)
12001
+ if (heedsRerun.length)
11939
12002
  rerun = true;
11940
12003
  });
11941
12004
  }
11942
12005
  if (rerun)
11943
12006
  files.push(filepath);
11944
12007
  }
11945
- return files;
12008
+ return Array.from(new Set(files));
11946
12009
  }
11947
12010
  async reportCoverage(allTestsRun) {
11948
12011
  if (!this.config.coverage.reportOnFailure && this.state.getCountOfFailedTests() > 0)
@@ -19092,7 +19155,9 @@ const cliOptionsConfig = {
19092
19155
  if (typeof browser === "boolean")
19093
19156
  return { enabled: browser };
19094
19157
  if (browser === "true" || browser === "false")
19095
- return { enabled: browser !== "false" };
19158
+ return { enabled: browser === "true" };
19159
+ if (browser === "yes" || browser === "no")
19160
+ return { enabled: browser === "yes" };
19096
19161
  if (typeof browser === "string")
19097
19162
  return { enabled: true, name: browser };
19098
19163
  return browser;
@@ -19253,11 +19318,28 @@ const cliOptionsConfig = {
19253
19318
  }
19254
19319
  },
19255
19320
  inspect: {
19256
- description: "Enable Node.js inspector"
19321
+ description: "Enable Node.js inspector (default: 127.0.0.1:9229)",
19322
+ argument: "[[host:]port]",
19323
+ transform(portOrEnabled) {
19324
+ if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
19325
+ return true;
19326
+ if (portOrEnabled === "false" || portOrEnabled === "no")
19327
+ return false;
19328
+ return portOrEnabled;
19329
+ }
19257
19330
  },
19258
19331
  inspectBrk: {
19259
- description: "Enable Node.js inspector with break"
19332
+ description: "Enable Node.js inspector and break before the test starts",
19333
+ argument: "[[host:]port]",
19334
+ transform(portOrEnabled) {
19335
+ if (portOrEnabled === 0 || portOrEnabled === "true" || portOrEnabled === "yes")
19336
+ return true;
19337
+ if (portOrEnabled === "false" || portOrEnabled === "no")
19338
+ return false;
19339
+ return portOrEnabled;
19340
+ }
19260
19341
  },
19342
+ inspector: null,
19261
19343
  testTimeout: {
19262
19344
  description: "Default timeout of a test in milliseconds (default: 5000)",
19263
19345
  argument: "<timeout>"
@@ -1,5 +1,6 @@
1
1
  const defaultPort = 51204;
2
2
  const defaultBrowserPort = 63315;
3
+ const defaultInspectPort = 9229;
3
4
  const EXIT_CODE_RESTART = 43;
4
5
  const API_PATH = "/__vitest_api__";
5
6
  const extraInlineDeps = [
@@ -61,4 +62,4 @@ const globalApis = [
61
62
  "onTestFailed"
62
63
  ];
63
64
 
64
- export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
65
+ export { API_PATH as A, CONFIG_NAMES as C, EXIT_CODE_RESTART as E, defaultBrowserPort as a, defaultInspectPort as b, configFiles as c, defaultPort as d, extraInlineDeps as e, globalApis as g, workspacesFiles as w };
@@ -5,7 +5,7 @@ import { distDir } from '../path.js';
5
5
  import { g as getWorkerState } from './global.CkGT_TMy.js';
6
6
  import { r as rpc } from './rpc.joBhAkyK.js';
7
7
  import { t as takeCoverageInsideWorker } from './coverage.E7sG1b3r.js';
8
- import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.vyF1kALR.js';
8
+ import { l as loadDiffConfig, a as loadSnapshotSerializers } from './setup-common.A1De6efh.js';
9
9
 
10
10
  function setupChaiConfig(config) {
11
11
  Object.assign(chai.config, config);
@@ -1,7 +1,7 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
2
  import { b as bench } from './benchmark.eeqk2rd8.js';
3
3
  import { i as isFirstRun, a as runOnce } from './run-once.Olz_Zkd8.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.JYQecGiw.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.Fxjax7rQ.js';
5
5
  import { g as getWorkerState } from './global.CkGT_TMy.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';
@@ -4,10 +4,10 @@ import { a as isNode, r as relativePath } from './index.ir9i0ywP.js';
4
4
  import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, getTests, hasFailed, getSuites } from '@vitest/runner/utils';
5
5
  import c from 'picocolors';
6
6
  import { getSafeTimers, notNullish, inspect, positionToOffset, lineSplitRE, highlight, shuffle } from '@vitest/utils';
7
+ import { g as getFullName, h as hasFailedSnapshot } from './tasks.IknbGB2n.js';
7
8
  import { performance } from 'node:perf_hooks';
8
- import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.tUKE_2UJ.js';
9
+ import { UNKNOWN_TEST_ID } from '../chunks/runtime-console.kbFEN7E-.js';
9
10
  import { a as slash, t as toArray, b as isPrimitive } from './base.Xt0Omgh7.js';
10
- import { g as getFullName, h as hasFailedSnapshot } from './tasks.IknbGB2n.js';
11
11
  import { isCI } from 'std-env';
12
12
  import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
13
13
  import nodeos__default, { hostname } from 'node:os';
@@ -1031,8 +1031,12 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
1031
1031
  logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
1032
1032
  const siblings = group.tasks.filter((i) => {
1033
1033
  var _a2;
1034
- return ((_a2 = i.result) == null ? void 0 : _a2.benchmark) && i !== bench;
1034
+ return i.meta.benchmark && ((_a2 = i.result) == null ? void 0 : _a2.benchmark) && i !== bench;
1035
1035
  }).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
1036
+ if (siblings.length === 0) {
1037
+ logger.log("");
1038
+ continue;
1039
+ }
1036
1040
  for (const sibling of siblings) {
1037
1041
  const number = `${(sibling.result.benchmark.mean / bench.result.benchmark.mean).toFixed(2)}x`;
1038
1042
  logger.log(` ${c.green(number)} ${c.gray("faster than")} ${sibling.name}`);
@@ -3102,7 +3106,7 @@ function generateCodeFrame(source, indent = 0, loc, range = 2) {
3102
3106
  if (j < 0 || j >= lines.length)
3103
3107
  continue;
3104
3108
  const lineLength = lines[j].length;
3105
- if (lineLength > 200)
3109
+ if (stripAnsi(lines[j]).length > 200)
3106
3110
  return "";
3107
3111
  res.push(lineNo(j + 1) + cliTruncate(lines[j].replace(/\t/g, " "), columns - 5 - indent));
3108
3112
  if (j === i) {
@@ -4324,7 +4328,7 @@ createLogUpdate(process$2.stdout);
4324
4328
 
4325
4329
  createLogUpdate(process$2.stderr);
4326
4330
 
4327
- var version = "1.4.0";
4331
+ var version = "1.5.0";
4328
4332
 
4329
4333
  const HIGHLIGHT_SUPPORTED_EXTS = new Set(["js", "ts"].flatMap((lang) => [
4330
4334
  `.${lang}`,
@@ -4790,7 +4794,7 @@ function renderBenchmark(task, tasks) {
4790
4794
  result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benches.length && benches.length > 2 ? c.bold(c.gray(" slowest")) : ""
4791
4795
  ].join(" ");
4792
4796
  }
4793
- function renderTree(tasks, options, level = 0) {
4797
+ function renderTree(tasks, options, level = 0, shallow = false) {
4794
4798
  var _a, _b, _c, _d, _e, _f;
4795
4799
  const output = [];
4796
4800
  let idx = 0;
@@ -4829,7 +4833,7 @@ ${padding}`;
4829
4833
  output.push(` ${c.gray(cliTruncate(out, getCols(-3)))}`);
4830
4834
  }
4831
4835
  }
4832
- if (task.type === "suite" && task.tasks.length > 0) {
4836
+ if (!shallow && task.type === "suite" && task.tasks.length > 0) {
4833
4837
  if ((_f = task.result) == null ? void 0 : _f.state)
4834
4838
  output.push(renderTree(task.tasks, options, level + 1));
4835
4839
  }
@@ -4896,6 +4900,27 @@ class TableReporter extends BaseReporter {
4896
4900
  this.renderer.update(files);
4897
4901
  }
4898
4902
  }
4903
+ onTaskUpdate(packs) {
4904
+ var _a, _b;
4905
+ if (this.isTTY)
4906
+ return;
4907
+ for (const pack of packs) {
4908
+ const task = this.ctx.state.idMap.get(pack[0]);
4909
+ if (task && task.type === "suite" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
4910
+ const benches = task.tasks.filter((t) => t.meta.benchmark);
4911
+ if (benches.length > 0 && benches.every((t) => {
4912
+ var _a2;
4913
+ return ((_a2 = t.result) == null ? void 0 : _a2.state) !== "run";
4914
+ })) {
4915
+ let title = ` ${getStateSymbol(task)} ${getFullName(task, c.dim(" > "))}`;
4916
+ if (task.result.duration != null && task.result.duration > this.ctx.config.slowTestThreshold)
4917
+ title += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
4918
+ this.ctx.logger.log(title);
4919
+ this.ctx.logger.log(renderTree(benches, this.rendererOptions, 1, true));
4920
+ }
4921
+ }
4922
+ }
4923
+ }
4899
4924
  async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
4900
4925
  await this.stopListRender();
4901
4926
  this.ctx.logger.log();
@@ -0,0 +1,54 @@
1
+ import { createRequire } from 'node:module';
2
+
3
+ const __require = createRequire(import.meta.url);
4
+ let inspector;
5
+ let session;
6
+ function setupInspect(ctx) {
7
+ const config = ctx.config;
8
+ const isEnabled = config.inspector.enabled;
9
+ if (isEnabled) {
10
+ inspector = __require("node:inspector");
11
+ const isOpen = inspector.url() !== void 0;
12
+ if (!isOpen) {
13
+ inspector.open(
14
+ config.inspector.port,
15
+ config.inspector.host,
16
+ config.inspector.waitForDebugger
17
+ );
18
+ if (config.inspectBrk) {
19
+ const firstTestFile = ctx.files[0];
20
+ if (firstTestFile) {
21
+ session = new inspector.Session();
22
+ session.connect();
23
+ session.post("Debugger.enable");
24
+ session.post("Debugger.setBreakpointByUrl", {
25
+ lineNumber: 0,
26
+ url: new URL(firstTestFile, import.meta.url).href
27
+ });
28
+ }
29
+ }
30
+ }
31
+ }
32
+ const keepOpen = shouldKeepOpen(config);
33
+ return function cleanup() {
34
+ if (isEnabled && !keepOpen && inspector) {
35
+ inspector.close();
36
+ session == null ? void 0 : session.disconnect();
37
+ }
38
+ };
39
+ }
40
+ function closeInspector(config) {
41
+ const keepOpen = shouldKeepOpen(config);
42
+ if (inspector && !keepOpen) {
43
+ inspector.close();
44
+ session == null ? void 0 : session.disconnect();
45
+ }
46
+ }
47
+ function shouldKeepOpen(config) {
48
+ var _a, _b, _c, _d, _e, _f, _g, _h;
49
+ const isIsolatedSingleThread = config.pool === "threads" && ((_b = (_a = config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.isolate) === false && ((_d = (_c = config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.singleThread);
50
+ const isIsolatedSingleFork = config.pool === "forks" && ((_f = (_e = config.poolOptions) == null ? void 0 : _e.forks) == null ? void 0 : _f.isolate) === false && ((_h = (_g = config.poolOptions) == null ? void 0 : _g.forks) == null ? void 0 : _h.singleFork);
51
+ return config.watch && (isIsolatedSingleFork || isIsolatedSingleThread);
52
+ }
53
+
54
+ export { closeInspector as c, setupInspect as s };