vitest 0.18.1 → 0.20.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 (38) hide show
  1. package/LICENSE.md +5 -5
  2. package/dist/browser.d.ts +1890 -0
  3. package/dist/browser.mjs +22 -0
  4. package/dist/{chunk-api-setup.9d3f7670.mjs → chunk-api-setup.7c4c8879.mjs} +24 -6
  5. package/dist/{chunk-constants.d4406290.mjs → chunk-constants.16825f0c.mjs} +5 -4
  6. package/dist/{chunk-env-node.bbba78e5.mjs → chunk-defaults.1c51d585.mjs} +461 -457
  7. package/dist/{chunk-install-pkg.2dcb2c04.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
  8. package/dist/chunk-integrations-globals.56a11010.mjs +26 -0
  9. package/dist/{chunk-utils-global.0a7416cf.mjs → chunk-mock-date.9160e13b.mjs} +16 -41
  10. package/dist/chunk-node-git.43dbdd42.mjs +1139 -0
  11. package/dist/chunk-runtime-chain.b6c2cdbc.mjs +2041 -0
  12. package/dist/chunk-runtime-error.0aa0dc06.mjs +648 -0
  13. package/dist/{chunk-runtime-chain.b60d57da.mjs → chunk-runtime-hooks.3ee34848.mjs} +14 -2014
  14. package/dist/{chunk-runtime-mocker.1d853e3a.mjs → chunk-runtime-mocker.0a8f7c5e.mjs} +23 -17
  15. package/dist/{chunk-runtime-rpc.9d1f4c48.mjs → chunk-runtime-rpc.dbf0b31d.mjs} +3 -1
  16. package/dist/chunk-utils-global.fa20c2f6.mjs +5 -0
  17. package/dist/{chunk-utils-source-map.c03f8bc4.mjs → chunk-utils-source-map.8198ebd9.mjs} +2 -2
  18. package/dist/chunk-utils-timers.b48455ed.mjs +27 -0
  19. package/dist/chunk-vite-node-client.a247c2c2.mjs +320 -0
  20. package/dist/chunk-vite-node-debug.c5887932.mjs +76 -0
  21. package/dist/{chunk-vite-node-externalize.6956d2d9.mjs → chunk-vite-node-externalize.2e90dadf.mjs} +165 -1182
  22. package/dist/{chunk-vite-node-utils.8077cd3c.mjs → chunk-vite-node-utils.9dfd1e3f.mjs} +4 -312
  23. package/dist/cli.mjs +10 -10
  24. package/dist/config.cjs +6 -3
  25. package/dist/config.d.ts +2 -0
  26. package/dist/config.mjs +6 -3
  27. package/dist/entry.mjs +17 -598
  28. package/dist/index.d.ts +81 -6
  29. package/dist/index.mjs +10 -5
  30. package/dist/loader.mjs +35 -0
  31. package/dist/node.d.ts +71 -4
  32. package/dist/node.mjs +13 -12
  33. package/dist/suite.mjs +15 -0
  34. package/dist/vendor-index.61438b77.mjs +335 -0
  35. package/dist/{vendor-index.4bf9c627.mjs → vendor-index.62ce5c33.mjs} +11 -343
  36. package/dist/worker.mjs +9 -6
  37. package/package.json +12 -4
  38. package/dist/chunk-integrations-globals.00b6e1ad.mjs +0 -23
@@ -1,14 +1,15 @@
1
1
  import path$2 from 'path';
2
2
  import fs$2 from 'fs';
3
- import require$$0 from 'util';
3
+ import util from 'util';
4
4
  import childProcess$1 from 'child_process';
5
- import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.4bf9c627.mjs';
6
- import require$$0$1 from 'os';
5
+ import { p as pathKey, m as mergeStream$1, g as getStream$1, c as crossSpawn$1 } from './vendor-index.62ce5c33.mjs';
6
+ import { s as signalExit, o as onetime$1 } from './vendor-index.61438b77.mjs';
7
+ import require$$0 from 'os';
7
8
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
8
- import 'assert';
9
- import 'events';
10
9
  import 'buffer';
11
10
  import 'stream';
11
+ import 'assert';
12
+ import 'events';
12
13
 
13
14
  var findUp$1 = {exports: {}};
14
15
 
@@ -206,7 +207,7 @@ var pLocate_1 = pLocate$1;
206
207
 
207
208
  const path$1 = path$2;
208
209
  const fs$1 = fs$2;
209
- const {promisify: promisify$1} = require$$0;
210
+ const {promisify: promisify$1} = util;
210
211
  const pLocate = pLocate_1;
211
212
 
212
213
  const fsStat = promisify$1(fs$1.stat);
@@ -275,7 +276,7 @@ locatePath.exports.sync = (paths, options) => {
275
276
  var pathExists = {exports: {}};
276
277
 
277
278
  const fs = fs$2;
278
- const {promisify} = require$$0;
279
+ const {promisify} = util;
279
280
 
280
281
  const pAccess = promisify(fs.access);
281
282
 
@@ -758,7 +759,7 @@ standard:"posix"};
758
759
  const SIGRTMIN=34;
759
760
  const SIGRTMAX=64;realtime.SIGRTMAX=SIGRTMAX;
760
761
 
761
- Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0$1;
762
+ Object.defineProperty(signals,"__esModule",{value:true});signals.getSignals=void 0;var _os$1=require$$0;
762
763
 
763
764
  var _core=core;
764
765
  var _realtime$1=realtime;
@@ -793,7 +794,7 @@ const number=supported?constantSignal:defaultNumber;
793
794
  return {name,number,description,supported,action,forced,standard};
794
795
  };
795
796
 
796
- Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0$1;
797
+ Object.defineProperty(main,"__esModule",{value:true});main.signalsByNumber=main.signalsByName=void 0;var _os=require$$0;
797
798
 
798
799
  var _signals=signals;
799
800
  var _realtime=realtime;
@@ -1006,7 +1007,7 @@ stdio.exports.node = options => {
1006
1007
  return [...stdio, 'ipc'];
1007
1008
  };
1008
1009
 
1009
- const os = require$$0$1;
1010
+ const os = require$$0;
1010
1011
  const onExit = signalExit.exports;
1011
1012
 
1012
1013
  const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
@@ -0,0 +1,26 @@
1
+ import { g as globalApis } from './chunk-constants.16825f0c.mjs';
2
+ import { i as index } from './chunk-runtime-hooks.3ee34848.mjs';
3
+ import 'url';
4
+ import './chunk-mock-date.9160e13b.mjs';
5
+ import 'path';
6
+ import 'tty';
7
+ import 'local-pkg';
8
+ import './chunk-runtime-chain.b6c2cdbc.mjs';
9
+ import 'util';
10
+ import 'chai';
11
+ import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
+ import './chunk-runtime-rpc.dbf0b31d.mjs';
13
+ import './chunk-utils-global.fa20c2f6.mjs';
14
+ import './chunk-utils-timers.b48455ed.mjs';
15
+ import 'fs';
16
+ import './chunk-utils-source-map.8198ebd9.mjs';
17
+ import './spy.mjs';
18
+ import 'tinyspy';
19
+
20
+ function registerApiGlobally() {
21
+ globalApis.forEach((api) => {
22
+ globalThis[api] = index[api];
23
+ });
24
+ }
25
+
26
+ export { registerApiGlobally };
@@ -1,4 +1,4 @@
1
- import path from 'path';
1
+ import path, { relative as relative$1 } from 'path';
2
2
  import require$$0 from 'tty';
3
3
  import { isPackageExists } from 'local-pkg';
4
4
 
@@ -246,10 +246,6 @@ const _path = /*#__PURE__*/Object.freeze({
246
246
  ..._path
247
247
  });
248
248
 
249
- function getWorkerState() {
250
- return globalThis.__vitest_worker__;
251
- }
252
-
253
249
  const RealDate = Date;
254
250
  let now = null;
255
251
  class MockDate extends RealDate {
@@ -456,34 +452,11 @@ function getNames(task) {
456
452
  return names;
457
453
  }
458
454
 
459
- const {
460
- setTimeout: safeSetTimeout,
461
- setInterval: safeSetInterval,
462
- clearInterval: safeClearInterval,
463
- clearTimeout: safeClearTimeout
464
- } = globalThis;
465
- function withSafeTimers(fn) {
466
- const currentSetTimeout = globalThis.setTimeout;
467
- const currentSetInterval = globalThis.setInterval;
468
- const currentClearInterval = globalThis.clearInterval;
469
- const currentClearTimeout = globalThis.clearTimeout;
470
- try {
471
- globalThis.setTimeout = safeSetTimeout;
472
- globalThis.setInterval = safeSetInterval;
473
- globalThis.clearInterval = safeClearInterval;
474
- globalThis.clearTimeout = safeClearTimeout;
475
- const result = fn();
476
- return result;
477
- } finally {
478
- globalThis.setTimeout = currentSetTimeout;
479
- globalThis.setInterval = currentSetInterval;
480
- globalThis.clearInterval = currentClearInterval;
481
- globalThis.clearTimeout = currentClearTimeout;
482
- }
483
- }
484
-
485
- const isNode = typeof process !== "undefined" && typeof process.platform !== "undefined";
455
+ var _a;
456
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
457
+ const isBrowser = typeof window !== "undefined";
486
458
  const isWindows = isNode && process.platform === "win32";
459
+ const relativePath = isBrowser ? relative$1 : relative;
487
460
  function partitionSuiteChildren(suite) {
488
461
  let tasksGroup = [];
489
462
  const tasksGroups = [];
@@ -499,15 +472,15 @@ function partitionSuiteChildren(suite) {
499
472
  tasksGroups.push(tasksGroup);
500
473
  return tasksGroups;
501
474
  }
502
- function resetModules() {
503
- const modules = getWorkerState().moduleCache;
504
- const vitestPaths = [
475
+ function resetModules(modules, resetMocks = false) {
476
+ const skipPaths = [
505
477
  /\/vitest\/dist\//,
506
478
  /vitest-virtual-\w+\/dist/,
507
- /@vitest\/dist/
479
+ /@vitest\/dist/,
480
+ ...!resetMocks ? [/^mock:/] : []
508
481
  ];
509
482
  modules.forEach((_, path) => {
510
- if (vitestPaths.some((re) => re.test(path)))
483
+ if (skipPaths.some((re) => re.test(path)))
511
484
  return;
512
485
  modules.delete(path);
513
486
  });
@@ -515,9 +488,10 @@ function resetModules() {
515
488
  function getFullName(task) {
516
489
  return getNames(task).join(picocolors.exports.dim(" > "));
517
490
  }
518
- async function ensurePackageInstalled(dependency, promptInstall = !process.env.CI && process.stdout.isTTY) {
519
- if (isPackageExists(dependency))
491
+ async function ensurePackageInstalled(dependency, root) {
492
+ if (isPackageExists(dependency, { paths: [root] }))
520
493
  return true;
494
+ const promptInstall = !process.env.CI && process.stdout.isTTY;
521
495
  process.stderr.write(picocolors.exports.red(`${picocolors.exports.inverse(picocolors.exports.red(" MISSING DEP "))} Can not find dependency '${dependency}'
522
496
 
523
497
  `));
@@ -530,7 +504,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
530
504
  message: picocolors.exports.reset(`Do you want to install ${picocolors.exports.green(dependency)}?`)
531
505
  });
532
506
  if (install) {
533
- await (await import('./chunk-install-pkg.2dcb2c04.mjs')).installPackage(dependency, { dev: true });
507
+ await (await import('./chunk-install-pkg.6c6dc0c2.mjs')).installPackage(dependency, { dev: true });
534
508
  process.stderr.write(picocolors.exports.yellow(`
535
509
  Package ${dependency} installed, re-run the command to start.
536
510
  `));
@@ -567,6 +541,7 @@ function getCallLastIndex(code) {
567
541
  }
568
542
  return null;
569
543
  }
544
+ isNode ? relative : relative$1;
570
545
  class AggregateErrorPonyfill extends Error {
571
546
  constructor(errors, message = "") {
572
547
  super(message);
@@ -574,4 +549,4 @@ class AggregateErrorPonyfill extends Error {
574
549
  }
575
550
  }
576
551
 
577
- export { AggregateErrorPonyfill as A, safeSetInterval as B, safeClearInterval as C, getSuites as D, shuffle as E, toArray as F, normalize as G, deepMerge as H, toNamespacedPath as I, ensurePackageInstalled as J, stdout as K, extname as L, isWindows as M, mergeSlashes as N, getType as O, getAllProperties as P, deepClone as Q, RealDate as R, partitionSuiteChildren as S, hasTests as T, getWorkerState as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, safeSetTimeout as f, getCallLastIndex as g, safeClearTimeout as h, isObject as i, join as j, resetModules as k, notNullish as l, mockDate as m, noop as n, basename as o, picocolors as p, resolve as q, resetDate as r, slash as s, isAbsolute as t, relative as u, isNode as v, withSafeTimers as w, getTests as x, hasFailed as y, hasFailedSnapshot as z };
552
+ export { AggregateErrorPonyfill as A, isAbsolute as B, relative as C, getTests as D, hasFailedSnapshot as E, getSuites as F, normalize as G, deepMerge as H, toNamespacedPath as I, ensurePackageInstalled as J, stdout as K, extname as L, isWindows as M, mergeSlashes as N, getAllProperties as O, RealDate as R, resetModules as a, getNames as b, assertTypes as c, dirname as d, getFullName as e, notNullish as f, getCallLastIndex as g, deepClone as h, isObject as i, join as j, getType as k, isNode as l, mockDate as m, noop as n, relativePath as o, picocolors as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, resolve as y, basename as z };