vitest 0.29.7 → 0.30.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 (60) hide show
  1. package/LICENSE.md +3 -266
  2. package/dist/browser.d.ts +16 -4
  3. package/dist/browser.js +5 -4
  4. package/dist/child.js +12 -17
  5. package/dist/{chunk-api-setup.ac7748ac.js → chunk-api-setup.6662587e.js} +65 -51
  6. package/dist/{chunk-install-pkg.863031f2.js → chunk-install-pkg.6450b372.js} +33 -32
  7. package/dist/chunk-integrations-globals.d419838f.js +26 -0
  8. package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
  9. package/dist/cli-wrapper.js +6 -5
  10. package/dist/cli.js +27 -26
  11. package/dist/config.cjs +15 -7
  12. package/dist/config.d.ts +15 -8
  13. package/dist/config.js +10 -6
  14. package/dist/coverage.d.ts +5 -2
  15. package/dist/coverage.js +6 -0
  16. package/dist/entry.js +35 -34
  17. package/dist/environments.d.ts +5 -2
  18. package/dist/environments.js +1 -1
  19. package/dist/index.d.ts +17 -21
  20. package/dist/index.js +9 -10
  21. package/dist/loader.js +396 -12
  22. package/dist/node.d.ts +9 -7
  23. package/dist/node.js +28 -30
  24. package/dist/runners.d.ts +5 -2
  25. package/dist/runners.js +34 -30
  26. package/dist/{types-fafda418.d.ts → types-f03c83c4.d.ts} +243 -317
  27. package/dist/utils.d.ts +1 -0
  28. package/dist/utils.js +1 -0
  29. package/dist/{chunk-node-pkg.f9696901.js → vendor-cli-api.c04eaa34.js} +3858 -5514
  30. package/dist/vendor-constants.538d9b49.js +54 -0
  31. package/dist/{chunk-integrations-coverage.e0a6acd2.js → vendor-coverage.a585b712.js} +5 -5
  32. package/dist/{chunk-runtime-mocker.344fec90.js → vendor-execute.8eaab47b.js} +9 -12
  33. package/dist/vendor-global.6795f91f.js +8 -0
  34. package/dist/vendor-index.4f82d248.js +161 -0
  35. package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
  36. package/dist/{chunk-integrations-utils.d7c85bd9.js → vendor-index.81b9e499.js} +22 -21
  37. package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
  38. package/dist/vendor-index.fad2598b.js +44 -0
  39. package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
  40. package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
  41. package/dist/{chunk-runtime-rpc.1b5714dc.js → vendor-rpc.4d3d7a54.js} +5 -5
  42. package/dist/{chunk-integrations-run-once.a2b4758b.js → vendor-run-once.69ce7172.js} +3 -2
  43. package/dist/{chunk-runtime-setup.a49dc2f9.js → vendor-setup.common.cef38f4e.js} +2 -2
  44. package/dist/vendor-tasks.042d6084.js +14 -0
  45. package/dist/{chunk-utils-import.39ffe9c5.js → vendor-vi.a3ff54b1.js} +262 -3147
  46. package/dist/worker.js +13 -19
  47. package/package.json +40 -34
  48. package/utils.d.ts +1 -0
  49. package/dist/chunk-constants.bc18a549.js +0 -36
  50. package/dist/chunk-integrations-globals.a473e88a.js +0 -27
  51. package/dist/chunk-snapshot-env.a347d647.js +0 -11
  52. package/dist/chunk-utils-base.81f83dbd.js +0 -88
  53. package/dist/chunk-utils-env.04ffbef7.js +0 -70
  54. package/dist/chunk-utils-tasks.b41c8284.js +0 -107
  55. package/dist/env-afee91f0.d.ts +0 -10
  56. package/dist/vendor-index.783e7f3e.js +0 -71
  57. package/dist/vendor-index.bdee400f.js +0 -396
  58. package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
  59. /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
  60. /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
@@ -0,0 +1,44 @@
1
+ import { relative } from 'pathe';
2
+ import 'std-env';
3
+ import '@vitest/runner/utils';
4
+ import '@vitest/utils';
5
+ import { g as getWorkerState } from './vendor-global.6795f91f.js';
6
+
7
+ var _a;
8
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
9
+
10
+ const isWindows = isNode && process.platform === "win32";
11
+ function getRunMode() {
12
+ return getWorkerState().config.mode;
13
+ }
14
+ function isRunningInBenchmark() {
15
+ return getRunMode() === "benchmark";
16
+ }
17
+ const relativePath = relative;
18
+ function resetModules(modules, resetMocks = false) {
19
+ const skipPaths = [
20
+ // Vitest
21
+ /\/vitest\/dist\//,
22
+ /\/vite-node\/dist\//,
23
+ // yarn's .store folder
24
+ /vitest-virtual-\w+\/dist/,
25
+ // cnpm
26
+ /@vitest\/dist/,
27
+ // don't clear mocks
28
+ ...!resetMocks ? [/^mock:/] : []
29
+ ];
30
+ modules.forEach((mod, path) => {
31
+ if (skipPaths.some((re) => re.test(path)))
32
+ return;
33
+ modules.invalidateModule(mod);
34
+ });
35
+ }
36
+ function removeUndefinedValues(obj) {
37
+ for (const key in Object.keys(obj)) {
38
+ if (obj[key] === void 0)
39
+ delete obj[key];
40
+ }
41
+ return obj;
42
+ }
43
+
44
+ export { removeUndefinedValues as a, isWindows as b, resetModules as c, isRunningInBenchmark as d, isNode as i, relativePath as r };
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
1
+ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.76cdd49e.js';
2
2
 
3
3
  function _mergeNamespaces(n, m) {
4
4
  m.forEach(function (e) {
@@ -141,7 +141,7 @@ if (typeof root.EventTarget === "undefined" || !isConstructor(root.Event)) {
141
141
 
142
142
  var index = /*#__PURE__*/_mergeNamespaces({
143
143
  __proto__: null,
144
- 'default': eventTargetPolyfill
144
+ default: eventTargetPolyfill
145
145
  }, [eventTargetPolyfill]);
146
146
 
147
147
  export { index as i };
@@ -1,8 +1,11 @@
1
- import inspector from 'node:inspector';
1
+ import { createRequire } from 'node:module';
2
2
 
3
+ const __require = createRequire(import.meta.url);
4
+ let inspector;
3
5
  function setupInspect(config) {
4
6
  const isEnabled = config.inspect || config.inspectBrk;
5
7
  if (isEnabled) {
8
+ inspector = __require("node:inspector");
6
9
  const isOpen = inspector.url() !== void 0;
7
10
  if (!isOpen) {
8
11
  inspector.open();
@@ -12,7 +15,7 @@ function setupInspect(config) {
12
15
  }
13
16
  const keepOpen = config.watch && !config.isolate && config.singleThread;
14
17
  return function cleanup() {
15
- if (isEnabled && !keepOpen)
18
+ if (isEnabled && !keepOpen && inspector)
16
19
  inspector.close();
17
20
  };
18
21
  }
@@ -1,5 +1,5 @@
1
1
  import { getSafeTimers } from '@vitest/utils';
2
- import { g as getWorkerState } from './chunk-utils-env.04ffbef7.js';
2
+ import { g as getWorkerState } from './vendor-global.6795f91f.js';
3
3
 
4
4
  const { get } = Reflect;
5
5
  const safeRandom = Math.random;
@@ -32,13 +32,13 @@ function withSafeTimers(fn) {
32
32
  }
33
33
  }
34
34
  const promises = /* @__PURE__ */ new Set();
35
- const rpcDone = async () => {
35
+ async function rpcDone() {
36
36
  if (!promises.size)
37
37
  return;
38
38
  const awaitable = Array.from(promises);
39
39
  return Promise.all(awaitable);
40
- };
41
- const rpc = () => {
40
+ }
41
+ function rpc() {
42
42
  const { rpc: rpc2 } = getWorkerState();
43
43
  return new Proxy(rpc2, {
44
44
  get(target, p, handler) {
@@ -56,6 +56,6 @@ const rpc = () => {
56
56
  return safeSendCall;
57
57
  }
58
58
  });
59
- };
59
+ }
60
60
 
61
61
  export { rpcDone as a, rpc as r };
@@ -1,4 +1,5 @@
1
- import { g as getWorkerState } from './chunk-utils-env.04ffbef7.js';
1
+ import './vendor-index.fad2598b.js';
2
+ import { g as getWorkerState } from './vendor-global.6795f91f.js';
2
3
 
3
4
  const filesCount = /* @__PURE__ */ new Map();
4
5
  const cache = /* @__PURE__ */ new Map();
@@ -24,4 +25,4 @@ function resetRunOnceCounter() {
24
25
  filesCount.clear();
25
26
  }
26
27
 
27
- export { resetRunOnceCounter as a, isFirstRun as i, runOnce as r };
28
+ export { runOnce as a, isFirstRun as i, resetRunOnceCounter as r };
@@ -1,5 +1,5 @@
1
1
  import { setSafeTimers } from '@vitest/utils';
2
- import { a as resetRunOnceCounter } from './chunk-integrations-run-once.a2b4758b.js';
2
+ import { r as resetRunOnceCounter } from './vendor-run-once.69ce7172.js';
3
3
 
4
4
  let globalSetup = false;
5
5
  async function setupCommonEnv(config) {
@@ -10,7 +10,7 @@ async function setupCommonEnv(config) {
10
10
  globalSetup = true;
11
11
  setSafeTimers();
12
12
  if (config.globals)
13
- (await import('./chunk-integrations-globals.a473e88a.js')).registerApiGlobally();
13
+ (await import('./chunk-integrations-globals.d419838f.js')).registerApiGlobally();
14
14
  }
15
15
  function setupDefines(defines) {
16
16
  for (const key in defines)
@@ -0,0 +1,14 @@
1
+ import { getNames, getTests } from '@vitest/runner/utils';
2
+ import '@vitest/utils';
3
+
4
+ function hasFailedSnapshot(suite) {
5
+ return getTests(suite).some((s) => {
6
+ var _a, _b;
7
+ return (_b = (_a = s.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.some((e) => e && e.message && e.message.match(/Snapshot .* mismatched/));
8
+ });
9
+ }
10
+ function getFullName(task, separator = " > ") {
11
+ return getNames(task).join(separator);
12
+ }
13
+
14
+ export { getFullName as g, hasFailedSnapshot as h };