vitest 2.0.0-beta.10 → 2.0.0-beta.11

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 (64) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +3 -3
  3. package/dist/chunks/{integrations-globals.C6Ah-pUW.js → integrations-globals.CC2ed6Py.js} +9 -9
  4. package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
  5. package/dist/chunks/{runtime-console.DiVMr5d4.js → runtime-console.Ckl0vEQr.js} +25 -10
  6. package/dist/chunks/{runtime-runBaseTests.Cukyr5-I.js → runtime-runBaseTests.BXW_BJeO.js} +40 -32
  7. package/dist/cli.js +3 -3
  8. package/dist/config.cjs +42 -19
  9. package/dist/config.d.ts +1 -1
  10. package/dist/config.js +42 -20
  11. package/dist/coverage.d.ts +4 -4
  12. package/dist/coverage.js +98 -36
  13. package/dist/environments.d.ts +1 -1
  14. package/dist/environments.js +1 -1
  15. package/dist/execute.d.ts +1 -1
  16. package/dist/execute.js +2 -2
  17. package/dist/index.d.ts +34 -8
  18. package/dist/index.js +9 -9
  19. package/dist/node.d.ts +19 -6
  20. package/dist/node.js +24 -16
  21. package/dist/path.js +4 -1
  22. package/dist/{reporters-CYVC6LOl.d.ts → reporters-fiIq_dT9.d.ts} +118 -179
  23. package/dist/reporters.d.ts +1 -1
  24. package/dist/reporters.js +7 -7
  25. package/dist/runners.d.ts +1 -1
  26. package/dist/runners.js +98 -60
  27. package/dist/{suite-Dpu9EC_k.d.ts → suite-D4aoU9rI.d.ts} +1 -1
  28. package/dist/suite.d.ts +2 -2
  29. package/dist/suite.js +2 -2
  30. package/dist/utils.d.ts +1 -5
  31. package/dist/utils.js +1 -6
  32. package/dist/vendor/{base.Dln9yllP.js → base.C2DbLEfT.js} +4 -3
  33. package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
  34. package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.CMp8QfyL.js} +13 -14
  35. package/dist/vendor/{cac.CtYFkoSJ.js → cac.BcJW7n2j.js} +71 -37
  36. package/dist/vendor/{cli-api.CUtJc4r3.js → cli-api.C8t8m4__.js} +4012 -4828
  37. package/dist/vendor/{constants.TCjCaw2D.js → constants.BWsVtsAj.js} +5 -22
  38. package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
  39. package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
  40. package/dist/vendor/{execute.BHj6OMh4.js → execute.T3gg2ZK6.js} +174 -60
  41. package/dist/vendor/{index.B5SKBLvV.js → index.-dbR4KUi.js} +17 -9
  42. package/dist/vendor/{index.BOMEjpjj.js → index.BC5zhX9y.js} +960 -469
  43. package/dist/vendor/{index.CThipSqB.js → index.BMmMjLIQ.js} +2540 -2540
  44. package/dist/vendor/{index._7XLd8Kd.js → index.C9Thslzw.js} +2 -1
  45. package/dist/vendor/{index.D3hs2WiI.js → index.CQJ2m700.js} +3 -3
  46. package/dist/vendor/{index.kpsSqFiz.js → index.D4nqnQWz.js} +69 -73
  47. package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
  48. package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
  49. package/dist/vendor/{setup-common.DAu7t7mY.js → setup-common.uqZOEWuR.js} +30 -15
  50. package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
  51. package/dist/vendor/{utils.YuQ3LT2a.js → utils.DSO2UK15.js} +40 -25
  52. package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
  53. package/dist/vendor/{vi.hATFzZbX.js → vi.BPjl8cAZ.js} +266 -137
  54. package/dist/vendor/{vm.Ow-X2mkS.js → vm.CycSoHnJ.js} +151 -86
  55. package/dist/worker.js +31 -15
  56. package/dist/workers/forks.js +4 -4
  57. package/dist/workers/runVmTests.js +14 -13
  58. package/dist/workers/threads.js +4 -4
  59. package/dist/workers/vmForks.js +6 -6
  60. package/dist/workers/vmThreads.js +6 -6
  61. package/dist/workers.d.ts +2 -2
  62. package/dist/workers.js +9 -9
  63. package/package.json +11 -11
  64. package/suppress-warnings.cjs +1 -4
@@ -13,8 +13,9 @@ function isRunningInBenchmark() {
13
13
  const relativePath = relative;
14
14
  function removeUndefinedValues(obj) {
15
15
  for (const key in Object.keys(obj)) {
16
- if (obj[key] === void 0)
16
+ if (obj[key] === void 0) {
17
17
  delete obj[key];
18
+ }
18
19
  }
19
20
  return obj;
20
21
  }
@@ -1,7 +1,7 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
- import { b as bench } from './benchmark.BNLebNi5.js';
3
- import { i as isFirstRun, a as runOnce } from './run-once.DLomgGUH.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.hATFzZbX.js';
2
+ import { b as bench } from './benchmark.CMp8QfyL.js';
3
+ import { i as isFirstRun, a as runOnce } from './run-once.Db8Hgq9X.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.BPjl8cAZ.js';
5
5
  import { g as getWorkerState } from './global.7bFbnyXl.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';
@@ -29,10 +29,7 @@ var node = {
29
29
  async setupVM() {
30
30
  const vm = await import('node:vm');
31
31
  let context = vm.createContext();
32
- let global = vm.runInContext(
33
- "this",
34
- context
35
- );
32
+ let global = vm.runInContext("this", context);
36
33
  const contextGlobals = new Set(Object.getOwnPropertyNames(global));
37
34
  for (const [nodeGlobalsKey, descriptor] of nodeGlobals) {
38
35
  if (!contextGlobals.has(nodeGlobalsKey)) {
@@ -345,21 +342,20 @@ const OTHER_KEYS = [
345
342
  ];
346
343
  const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
347
344
 
348
- const skipKeys = [
349
- "window",
350
- "self",
351
- "top",
352
- "parent"
353
- ];
345
+ const skipKeys = ["window", "self", "top", "parent"];
354
346
  function getWindowKeys(global, win, additionalKeys = []) {
355
347
  const keysArray = [...additionalKeys, ...KEYS];
356
- const keys = new Set(keysArray.concat(Object.getOwnPropertyNames(win)).filter((k) => {
357
- if (skipKeys.includes(k))
358
- return false;
359
- if (k in global)
360
- return keysArray.includes(k);
361
- return true;
362
- }));
348
+ const keys = new Set(
349
+ keysArray.concat(Object.getOwnPropertyNames(win)).filter((k) => {
350
+ if (skipKeys.includes(k)) {
351
+ return false;
352
+ }
353
+ if (k in global) {
354
+ return keysArray.includes(k);
355
+ }
356
+ return true;
357
+ })
358
+ );
363
359
  return keys;
364
360
  }
365
361
  function isClassLikeName(name) {
@@ -372,14 +368,17 @@ function populateGlobal(global, win, options = {}) {
372
368
  const overrideObject = /* @__PURE__ */ new Map();
373
369
  for (const key of keys) {
374
370
  const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
375
- if (KEYS.includes(key) && key in global)
371
+ if (KEYS.includes(key) && key in global) {
376
372
  originals.set(key, global[key]);
373
+ }
377
374
  Object.defineProperty(global, key, {
378
375
  get() {
379
- if (overrideObject.has(key))
376
+ if (overrideObject.has(key)) {
380
377
  return overrideObject.get(key);
381
- if (boundFunction)
378
+ }
379
+ if (boundFunction) {
382
380
  return boundFunction;
381
+ }
383
382
  return win[key];
384
383
  },
385
384
  set(v) {
@@ -392,8 +391,9 @@ function populateGlobal(global, win, options = {}) {
392
391
  global.self = global;
393
392
  global.top = global;
394
393
  global.parent = global;
395
- if (global.global)
394
+ if (global.global) {
396
395
  global.global = global;
396
+ }
397
397
  if (global.document && global.document.defaultView) {
398
398
  Object.defineProperty(global.document, "defaultView", {
399
399
  get: () => global,
@@ -412,20 +412,23 @@ function populateGlobal(global, win, options = {}) {
412
412
  function catchWindowErrors(window) {
413
413
  let userErrorListenerCount = 0;
414
414
  function throwUnhandlerError(e) {
415
- if (userErrorListenerCount === 0 && e.error != null)
415
+ if (userErrorListenerCount === 0 && e.error != null) {
416
416
  process.emit("uncaughtException", e.error);
417
+ }
417
418
  }
418
419
  const addEventListener = window.addEventListener.bind(window);
419
420
  const removeEventListener = window.removeEventListener.bind(window);
420
421
  window.addEventListener("error", throwUnhandlerError);
421
422
  window.addEventListener = function(...args) {
422
- if (args[0] === "error")
423
+ if (args[0] === "error") {
423
424
  userErrorListenerCount++;
425
+ }
424
426
  return addEventListener.apply(this, args);
425
427
  };
426
428
  window.removeEventListener = function(...args) {
427
- if (args[0] === "error" && userErrorListenerCount)
429
+ if (args[0] === "error" && userErrorListenerCount) {
428
430
  userErrorListenerCount--;
431
+ }
429
432
  return removeEventListener.apply(this, args);
430
433
  };
431
434
  return function clearErrorHandlers() {
@@ -436,12 +439,7 @@ var jsdom = {
436
439
  name: "jsdom",
437
440
  transformMode: "web",
438
441
  async setupVM({ jsdom = {} }) {
439
- const {
440
- CookieJar,
441
- JSDOM,
442
- ResourceLoader,
443
- VirtualConsole
444
- } = await import('jsdom');
442
+ const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
445
443
  const {
446
444
  html = "<!DOCTYPE html>",
447
445
  userAgent,
@@ -455,21 +453,18 @@ var jsdom = {
455
453
  cookieJar = false,
456
454
  ...restOptions
457
455
  } = jsdom;
458
- let dom = new JSDOM(
459
- html,
460
- {
461
- pretendToBeVisual,
462
- resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
463
- runScripts,
464
- url,
465
- virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) : void 0,
466
- cookieJar: cookieJar ? new CookieJar() : void 0,
467
- includeNodeLocations,
468
- contentType,
469
- userAgent,
470
- ...restOptions
471
- }
472
- );
456
+ let dom = new JSDOM(html, {
457
+ pretendToBeVisual,
458
+ resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
459
+ runScripts,
460
+ url,
461
+ virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) : void 0,
462
+ cookieJar: cookieJar ? new CookieJar() : void 0,
463
+ includeNodeLocations,
464
+ contentType,
465
+ userAgent,
466
+ ...restOptions
467
+ });
473
468
  const clearWindowErrors = catchWindowErrors(dom.window);
474
469
  dom.window.Buffer = Buffer;
475
470
  dom.window.jsdom = dom;
@@ -502,12 +497,7 @@ var jsdom = {
502
497
  };
503
498
  },
504
499
  async setup(global, { jsdom = {} }) {
505
- const {
506
- CookieJar,
507
- JSDOM,
508
- ResourceLoader,
509
- VirtualConsole
510
- } = await import('jsdom');
500
+ const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
511
501
  const {
512
502
  html = "<!DOCTYPE html>",
513
503
  userAgent,
@@ -521,22 +511,21 @@ var jsdom = {
521
511
  cookieJar = false,
522
512
  ...restOptions
523
513
  } = jsdom;
524
- const dom = new JSDOM(
525
- html,
526
- {
527
- pretendToBeVisual,
528
- resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
529
- runScripts,
530
- url,
531
- virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
532
- cookieJar: cookieJar ? new CookieJar() : void 0,
533
- includeNodeLocations,
534
- contentType,
535
- userAgent,
536
- ...restOptions
537
- }
538
- );
539
- const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
514
+ const dom = new JSDOM(html, {
515
+ pretendToBeVisual,
516
+ resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
517
+ runScripts,
518
+ url,
519
+ virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
520
+ cookieJar: cookieJar ? new CookieJar() : void 0,
521
+ includeNodeLocations,
522
+ contentType,
523
+ userAgent,
524
+ ...restOptions
525
+ });
526
+ const { keys, originals } = populateGlobal(global, dom.window, {
527
+ bindFunctions: true
528
+ });
540
529
  const clearWindowErrors = catchWindowErrors(global);
541
530
  global.jsdom = dom;
542
531
  return {
@@ -574,8 +563,9 @@ var happy = {
574
563
  }
575
564
  });
576
565
  win.Buffer = Buffer;
577
- if (typeof structuredClone !== "undefined" && !win.structuredClone)
566
+ if (typeof structuredClone !== "undefined" && !win.structuredClone) {
578
567
  win.structuredClone = structuredClone;
568
+ }
579
569
  return {
580
570
  getVmContext() {
581
571
  return win;
@@ -639,13 +629,16 @@ var edge = {
639
629
  context.global = context;
640
630
  context.Buffer = Buffer;
641
631
  KEYS.forEach((key) => {
642
- if (key in global)
632
+ if (key in global) {
643
633
  context[key] = global[key];
634
+ }
644
635
  });
645
636
  return context;
646
637
  }
647
638
  });
648
- const { keys, originals } = populateGlobal(global, vm.context, { bindFunctions: true });
639
+ const { keys, originals } = populateGlobal(global, vm.context, {
640
+ bindFunctions: true
641
+ });
649
642
  return {
650
643
  teardown(global2) {
651
644
  keys.forEach((key) => delete global2[key]);
@@ -667,12 +660,15 @@ const envPackageNames = {
667
660
  "edge-runtime": "@edge-runtime/vm"
668
661
  };
669
662
  function getEnvPackageName(env) {
670
- if (env === "node")
663
+ if (env === "node") {
671
664
  return null;
672
- if (env in envPackageNames)
665
+ }
666
+ if (env in envPackageNames) {
673
667
  return envPackageNames[env];
674
- if (env[0] === "." || env[0] === "/")
668
+ }
669
+ if (env[0] === "." || env[0] === "/") {
675
670
  return null;
671
+ }
676
672
  return `vitest-environment-${env}`;
677
673
  }
678
674
 
@@ -16,8 +16,9 @@ function withSafeTimers(fn) {
16
16
  globalThis.clearTimeout = clearTimeout;
17
17
  globalThis.setImmediate = setImmediate;
18
18
  globalThis.clearImmediate = clearImmediate;
19
- if (globalThis.process)
19
+ if (globalThis.process) {
20
20
  globalThis.process.nextTick = nextTick;
21
+ }
21
22
  const result = fn();
22
23
  return result;
23
24
  } finally {
@@ -34,8 +35,9 @@ function withSafeTimers(fn) {
34
35
  }
35
36
  const promises = /* @__PURE__ */ new Set();
36
37
  async function rpcDone() {
37
- if (!promises.size)
38
+ if (!promises.size) {
38
39
  return;
40
+ }
39
41
  const awaitable = Array.from(promises);
40
42
  return Promise.all(awaitable);
41
43
  }
@@ -45,24 +47,33 @@ function createRuntimeRpc(options) {
45
47
  const onCancel = new Promise((resolve) => {
46
48
  setCancel = resolve;
47
49
  });
48
- const rpc2 = createSafeRpc(createBirpc(
49
- {
50
- onCancel: setCancel
51
- },
52
- {
53
- eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onCancel"],
54
- onTimeoutError(functionName, args) {
55
- var _a;
56
- let message = `[vitest-worker]: Timeout calling "${functionName}"`;
57
- if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId")
58
- message += ` with "${JSON.stringify(args)}"`;
59
- if (functionName === "onUnhandledError")
60
- message += ` with "${((_a = args[0]) == null ? void 0 : _a.message) || args[0]}"`;
61
- throw new Error(message);
50
+ const rpc2 = createSafeRpc(
51
+ createBirpc(
52
+ {
53
+ onCancel: setCancel
62
54
  },
63
- ...options
64
- }
65
- ));
55
+ {
56
+ eventNames: [
57
+ "onUserConsoleLog",
58
+ "onFinished",
59
+ "onCollected",
60
+ "onCancel"
61
+ ],
62
+ onTimeoutError(functionName, args) {
63
+ var _a;
64
+ let message = `[vitest-worker]: Timeout calling "${functionName}"`;
65
+ if (functionName === "fetch" || functionName === "transform" || functionName === "resolveId") {
66
+ message += ` with "${JSON.stringify(args)}"`;
67
+ }
68
+ if (functionName === "onUnhandledError") {
69
+ message += ` with "${((_a = args[0]) == null ? void 0 : _a.message) || args[0]}"`;
70
+ }
71
+ throw new Error(message);
72
+ },
73
+ ...options
74
+ }
75
+ )
76
+ );
66
77
  return {
67
78
  rpc: rpc2,
68
79
  onCancel
@@ -9,8 +9,9 @@ function runOnce(fn, key) {
9
9
  key = String(filesCount.get(filepath));
10
10
  }
11
11
  const id = `${filepath}:${key}`;
12
- if (!cache.has(id))
12
+ if (!cache.has(id)) {
13
13
  cache.set(id, fn());
14
+ }
14
15
  return cache.get(id);
15
16
  }
16
17
  function isFirstRun() {
@@ -1,51 +1,66 @@
1
1
  import { setSafeTimers } from '@vitest/utils';
2
2
  import { addSerializer } from '@vitest/snapshot';
3
- import { r as resetRunOnceCounter } from './run-once.DLomgGUH.js';
3
+ import { r as resetRunOnceCounter } from './run-once.Db8Hgq9X.js';
4
4
 
5
5
  let globalSetup = false;
6
6
  async function setupCommonEnv(config) {
7
7
  resetRunOnceCounter();
8
8
  setupDefines(config.defines);
9
9
  setupEnv(config.env);
10
- if (globalSetup)
10
+ if (globalSetup) {
11
11
  return;
12
+ }
12
13
  globalSetup = true;
13
14
  setSafeTimers();
14
- if (config.globals)
15
- (await import('../chunks/integrations-globals.C6Ah-pUW.js')).registerApiGlobally();
15
+ if (config.globals) {
16
+ (await import('../chunks/integrations-globals.CC2ed6Py.js')).registerApiGlobally();
17
+ }
16
18
  }
17
19
  function setupDefines(defines) {
18
- for (const key in defines)
20
+ for (const key in defines) {
19
21
  globalThis[key] = defines[key];
22
+ }
20
23
  }
21
24
  function setupEnv(env) {
22
- if (typeof process === "undefined")
25
+ if (typeof process === "undefined") {
23
26
  return;
27
+ }
24
28
  const { PROD, DEV, ...restEnvs } = env;
25
29
  process.env.PROD = PROD ? "1" : "";
26
30
  process.env.DEV = DEV ? "1" : "";
27
- for (const key in restEnvs)
31
+ for (const key in restEnvs) {
28
32
  process.env[key] = env[key];
33
+ }
29
34
  }
30
35
  async function loadDiffConfig(config, executor) {
31
- if (typeof config.diff !== "string")
36
+ if (typeof config.diff !== "string") {
32
37
  return;
38
+ }
33
39
  const diffModule = await executor.executeId(config.diff);
34
- if (diffModule && typeof diffModule.default === "object" && diffModule.default != null)
40
+ if (diffModule && typeof diffModule.default === "object" && diffModule.default != null) {
35
41
  return diffModule.default;
36
- else
37
- throw new Error(`invalid diff config file ${config.diff}. Must have a default export with config object`);
42
+ } else {
43
+ throw new Error(
44
+ `invalid diff config file ${config.diff}. Must have a default export with config object`
45
+ );
46
+ }
38
47
  }
39
48
  async function loadSnapshotSerializers(config, executor) {
40
49
  const files = config.snapshotSerializers;
41
50
  const snapshotSerializers = await Promise.all(
42
51
  files.map(async (file) => {
43
52
  const mo = await executor.executeId(file);
44
- if (!mo || typeof mo.default !== "object" || mo.default === null)
45
- throw new Error(`invalid snapshot serializer file ${file}. Must export a default object`);
53
+ if (!mo || typeof mo.default !== "object" || mo.default === null) {
54
+ throw new Error(
55
+ `invalid snapshot serializer file ${file}. Must export a default object`
56
+ );
57
+ }
46
58
  const config2 = mo.default;
47
- if (typeof config2.test !== "function" || typeof config2.serialize !== "function" && typeof config2.print !== "function")
48
- throw new Error(`invalid snapshot serializer in ${file}. Must have a 'test' method along with either a 'serialize' or 'print' method.`);
59
+ if (typeof config2.test !== "function" || typeof config2.serialize !== "function" && typeof config2.print !== "function") {
60
+ throw new TypeError(
61
+ `invalid snapshot serializer in ${file}. Must have a 'test' method along with either a 'serialize' or 'print' method.`
62
+ );
63
+ }
49
64
  return config2;
50
65
  })
51
66
  );
@@ -4,7 +4,9 @@ import '@vitest/utils';
4
4
  function hasFailedSnapshot(suite) {
5
5
  return getTests(suite).some((s) => {
6
6
  var _a, _b;
7
- return (_b = (_a = s.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.some((e) => typeof (e == null ? void 0 : e.message) === "string" && e.message.match(/Snapshot .* mismatched/));
7
+ return (_b = (_a = s.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.some(
8
+ (e) => typeof (e == null ? void 0 : e.message) === "string" && e.message.match(/Snapshot .* mismatched/)
9
+ );
8
10
  });
9
11
  }
10
12
  function getFullName(task, separator = " > ") {
@@ -1,6 +1,6 @@
1
1
  import { isAbsolute, relative, dirname, basename } from 'pathe';
2
2
  import c from 'picocolors';
3
- import { a as slash } from './base._gnK9Slw.js';
3
+ import { a as slash } from './base.CTYV4Gnz.js';
4
4
 
5
5
  const F_RIGHT = "\u2192";
6
6
  const F_DOWN = "\u2193";
@@ -40,8 +40,9 @@ const skipped = c.dim(c.gray(F_DOWN));
40
40
  function getCols(delta = 0) {
41
41
  var _a;
42
42
  let length = (_a = process.stdout) == null ? void 0 : _a.columns;
43
- if (!length || Number.isNaN(length))
43
+ if (!length || Number.isNaN(length)) {
44
44
  length = 30;
45
+ }
45
46
  return Math.max(length + delta, 0);
46
47
  }
47
48
  function divider(text, left, right) {
@@ -62,8 +63,9 @@ function divider(text, left, right) {
62
63
  }
63
64
  function formatTestPath(root, path) {
64
65
  var _a;
65
- if (isAbsolute(path))
66
+ if (isAbsolute(path)) {
66
67
  path = relative(root, path);
68
+ }
67
69
  const dir = dirname(path);
68
70
  const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
69
71
  const base = basename(path, ext);
@@ -71,17 +73,23 @@ function formatTestPath(root, path) {
71
73
  }
72
74
  function renderSnapshotSummary(rootDir, snapshots) {
73
75
  const summary = [];
74
- if (snapshots.added)
76
+ if (snapshots.added) {
75
77
  summary.push(c.bold(c.green(`${snapshots.added} written`)));
76
- if (snapshots.unmatched)
78
+ }
79
+ if (snapshots.unmatched) {
77
80
  summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
78
- if (snapshots.updated)
81
+ }
82
+ if (snapshots.updated) {
79
83
  summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
84
+ }
80
85
  if (snapshots.filesRemoved) {
81
- if (snapshots.didUpdate)
86
+ if (snapshots.didUpdate) {
82
87
  summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
83
- else
84
- summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
88
+ } else {
89
+ summary.push(
90
+ c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `))
91
+ );
92
+ }
85
93
  }
86
94
  if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
87
95
  const [head, ...tail] = snapshots.filesRemovedList;
@@ -91,13 +99,21 @@ function renderSnapshotSummary(rootDir, snapshots) {
91
99
  });
92
100
  }
93
101
  if (snapshots.unchecked) {
94
- if (snapshots.didUpdate)
102
+ if (snapshots.didUpdate) {
95
103
  summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
96
- else
104
+ } else {
97
105
  summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
106
+ }
98
107
  snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
99
- summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
100
- uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
108
+ summary.push(
109
+ `${c.gray(F_DOWN_RIGHT)} ${formatTestPath(
110
+ rootDir,
111
+ uncheckedFile.filePath
112
+ )}`
113
+ );
114
+ uncheckedFile.keys.forEach(
115
+ (key) => summary.push(` ${c.gray(F_DOT)} ${key}`)
116
+ );
101
117
  });
102
118
  }
103
119
  return summary;
@@ -109,8 +125,9 @@ function countTestErrors(tasks) {
109
125
  }, 0);
110
126
  }
111
127
  function getStateString(tasks, name = "tests", showTotal = true) {
112
- if (tasks.length === 0)
128
+ if (tasks.length === 0) {
113
129
  return c.dim(`no ${name}`);
130
+ }
114
131
  const passed = tasks.filter((i) => {
115
132
  var _a;
116
133
  return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
@@ -130,13 +147,16 @@ function getStateString(tasks, name = "tests", showTotal = true) {
130
147
  }
131
148
  function getStateSymbol(task) {
132
149
  var _a;
133
- if (task.mode === "skip" || task.mode === "todo")
150
+ if (task.mode === "skip" || task.mode === "todo") {
134
151
  return skipped;
135
- if (!task.result)
152
+ }
153
+ if (!task.result) {
136
154
  return c.gray("\xB7");
155
+ }
137
156
  if (task.result.state === "run") {
138
- if (task.type === "suite")
157
+ if (task.type === "suite") {
139
158
  return pointer;
159
+ }
140
160
  let spinner = spinnerMap.get(task);
141
161
  if (!spinner) {
142
162
  spinner = elegantSpinner();
@@ -181,16 +201,11 @@ function formatTimeString(date) {
181
201
  return date.toTimeString().split(" ")[0];
182
202
  }
183
203
  function formatProjectName(name, suffix = " ") {
184
- if (!name)
204
+ if (!name) {
185
205
  return "";
206
+ }
186
207
  const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
187
- const colors = [
188
- c.blue,
189
- c.yellow,
190
- c.cyan,
191
- c.green,
192
- c.magenta
193
- ];
208
+ const colors = [c.blue, c.yellow, c.cyan, c.green, c.magenta];
194
209
  return colors[index % colors.length](`|${name}|`) + suffix;
195
210
  }
196
211
 
@@ -4,7 +4,9 @@ var _a, _b;
4
4
  const REGEXP_WRAP_PREFIX = "$$vitest:";
5
5
  const processSend = (_a = process.send) == null ? void 0 : _a.bind(process);
6
6
  const processOn = (_b = process.on) == null ? void 0 : _b.bind(process);
7
- function createThreadsRpcOptions({ port }) {
7
+ function createThreadsRpcOptions({
8
+ port
9
+ }) {
8
10
  return {
9
11
  post: (v) => {
10
12
  port.postMessage(v);
@@ -23,8 +25,9 @@ function createForksRpcOptions(nodeV8) {
23
25
  },
24
26
  on(fn) {
25
27
  processOn("message", (message, ...extras) => {
26
- if (message == null ? void 0 : message.__tinypool_worker_message__)
28
+ if (message == null ? void 0 : message.__tinypool_worker_message__) {
27
29
  return;
30
+ }
28
31
  return fn(message, ...extras);
29
32
  });
30
33
  }
@@ -33,14 +36,18 @@ function createForksRpcOptions(nodeV8) {
33
36
  function unwrapSerializableConfig(config) {
34
37
  if (config.testNamePattern && typeof config.testNamePattern === "string") {
35
38
  const testNamePattern = config.testNamePattern;
36
- if (testNamePattern.startsWith(REGEXP_WRAP_PREFIX))
37
- config.testNamePattern = parseRegexp(testNamePattern.slice(REGEXP_WRAP_PREFIX.length));
39
+ if (testNamePattern.startsWith(REGEXP_WRAP_PREFIX)) {
40
+ config.testNamePattern = parseRegexp(
41
+ testNamePattern.slice(REGEXP_WRAP_PREFIX.length)
42
+ );
43
+ }
38
44
  }
39
45
  if (config.defines && Array.isArray(config.defines.keys) && config.defines.original) {
40
46
  const { keys, original } = config.defines;
41
47
  const defines = {};
42
- for (const key of keys)
48
+ for (const key of keys) {
43
49
  defines[key] = original[key];
50
+ }
44
51
  config.defines = defines;
45
52
  }
46
53
  return config;