vitest 0.20.2 → 0.21.1

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 (35) hide show
  1. package/LICENSE.md +29 -0
  2. package/dist/browser.d.ts +9 -1887
  3. package/dist/browser.mjs +7 -7
  4. package/dist/{chunk-api-setup.7c4c8879.mjs → chunk-api-setup.7a6ba7fb.mjs} +5 -5
  5. package/dist/{chunk-constants.16825f0c.mjs → chunk-constants.26dc9f85.mjs} +1 -1
  6. package/dist/{chunk-defaults.1c51d585.mjs → chunk-defaults.02abff90.mjs} +2 -2
  7. package/dist/{chunk-integrations-globals.56a11010.mjs → chunk-integrations-globals.44a8f047.mjs} +6 -6
  8. package/dist/{chunk-mock-date.9160e13b.mjs → chunk-mock-date.bc81a3ac.mjs} +11 -8
  9. package/dist/{chunk-node-git.43dbdd42.mjs → chunk-node-git.c2be9c49.mjs} +1 -1
  10. package/dist/{chunk-runtime-chain.b6c2cdbc.mjs → chunk-runtime-chain.98d42d89.mjs} +30 -21
  11. package/dist/{chunk-runtime-error.0aa0dc06.mjs → chunk-runtime-error.87a2b5a2.mjs} +12 -11
  12. package/dist/{chunk-runtime-hooks.3ee34848.mjs → chunk-runtime-hooks.453f8858.mjs} +4 -4
  13. package/dist/{chunk-runtime-mocker.0a8f7c5e.mjs → chunk-runtime-mocker.23b62bfa.mjs} +34 -12
  14. package/dist/{chunk-runtime-rpc.dbf0b31d.mjs → chunk-runtime-rpc.b50ab560.mjs} +1 -1
  15. package/dist/{chunk-utils-source-map.8198ebd9.mjs → chunk-utils-source-map.94107ee8.mjs} +1 -1
  16. package/dist/{chunk-vite-node-client.a247c2c2.mjs → chunk-vite-node-client.fdd9592c.mjs} +7 -3
  17. package/dist/{chunk-vite-node-debug.c5887932.mjs → chunk-vite-node-debug.09afb76f.mjs} +1 -1
  18. package/dist/{chunk-vite-node-externalize.45323563.mjs → chunk-vite-node-externalize.27aee038.mjs} +34 -18
  19. package/dist/chunk-vite-node-utils.f34df9d3.mjs +6887 -0
  20. package/dist/cli.mjs +8 -8
  21. package/dist/config.d.ts +2 -67
  22. package/dist/entry.mjs +7 -7
  23. package/dist/global-60f880c6.d.ts +1779 -0
  24. package/dist/index-4a906fa4.d.ts +164 -0
  25. package/dist/index.d.ts +29 -1903
  26. package/dist/index.mjs +5 -5
  27. package/dist/loader.mjs +73 -17
  28. package/dist/mocker-5e2a8e41.d.ts +3 -0
  29. package/dist/node.d.ts +7 -1667
  30. package/dist/node.mjs +9 -9
  31. package/dist/suite.mjs +4 -4
  32. package/dist/{vendor-index.de788b6a.mjs → vendor-index.ae96af6e.mjs} +14 -14
  33. package/dist/worker.mjs +6 -6
  34. package/package.json +11 -11
  35. package/dist/chunk-vite-node-utils.9dfd1e3f.mjs +0 -1114
package/dist/browser.mjs CHANGED
@@ -1,22 +1,22 @@
1
- export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.b6c2cdbc.mjs';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.3ee34848.mjs';
3
- export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.0aa0dc06.mjs';
1
+ export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.98d42d89.mjs';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.453f8858.mjs';
3
+ export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.87a2b5a2.mjs';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
7
  import 'util';
8
- import './chunk-mock-date.9160e13b.mjs';
8
+ import './chunk-mock-date.bc81a3ac.mjs';
9
9
  import 'path';
10
10
  import 'tty';
11
11
  import 'local-pkg';
12
12
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
13
- import './chunk-runtime-rpc.dbf0b31d.mjs';
13
+ import './chunk-runtime-rpc.b50ab560.mjs';
14
14
  import './chunk-utils-global.fa20c2f6.mjs';
15
15
  import './chunk-utils-timers.b48455ed.mjs';
16
16
  import 'fs';
17
- import './chunk-utils-source-map.8198ebd9.mjs';
17
+ import './chunk-utils-source-map.94107ee8.mjs';
18
18
  import './spy.mjs';
19
19
  import 'tinyspy';
20
- import './chunk-defaults.1c51d585.mjs';
20
+ import './chunk-defaults.02abff90.mjs';
21
21
  import 'module';
22
22
  import 'url';
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-client.a247c2c2.mjs';
2
+ import { c as createBirpc } from './chunk-vite-node-client.fdd9592c.mjs';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -9,15 +9,15 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import _url from 'url';
12
- import { A as API_PATH } from './chunk-constants.16825f0c.mjs';
13
- import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.8198ebd9.mjs';
12
+ import { A as API_PATH } from './chunk-constants.26dc9f85.mjs';
13
+ import { j as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.94107ee8.mjs';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-mock-date.9160e13b.mjs';
16
+ import './chunk-mock-date.bc81a3ac.mjs';
17
17
  import 'path';
18
18
  import 'tty';
19
19
  import 'local-pkg';
20
- import './chunk-vite-node-utils.9dfd1e3f.mjs';
20
+ import './chunk-vite-node-utils.f34df9d3.mjs';
21
21
  import 'assert';
22
22
  import 'util';
23
23
  import 'debug';
@@ -1,5 +1,5 @@
1
1
  import _url from 'url';
2
- import { y as resolve } from './chunk-mock-date.9160e13b.mjs';
2
+ import { y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
3
3
 
4
4
  const rootDir = resolve(_url.fileURLToPath(import.meta.url), "../../");
5
5
  const distDir = resolve(_url.fileURLToPath(import.meta.url), "../../dist");
@@ -1,7 +1,7 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { createRequire } from 'module';
3
3
  import _url from 'url';
4
- import { t as toArray, y as resolve } from './chunk-mock-date.9160e13b.mjs';
4
+ import { t as toArray, y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
5
5
  import { importModule } from 'local-pkg';
6
6
 
7
7
  /*
@@ -551,7 +551,7 @@ function isClassLikeName(name) {
551
551
  function populateGlobal(global, win, options = {}) {
552
552
  const { bindFunctions = false } = options;
553
553
  const keys = getWindowKeys(global, win);
554
- const originals = new Map(allowRewrite.map(([key]) => [key, global[key]]));
554
+ const originals = new Map(allowRewrite.filter((key) => key in global).map((key) => [key, global[key]]));
555
555
  const overrideObject = /* @__PURE__ */ new Map();
556
556
  for (const key of keys) {
557
557
  const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
@@ -1,19 +1,19 @@
1
- import { g as globalApis } from './chunk-constants.16825f0c.mjs';
2
- import { i as index } from './chunk-runtime-hooks.3ee34848.mjs';
1
+ import { g as globalApis } from './chunk-constants.26dc9f85.mjs';
2
+ import { i as index } from './chunk-runtime-hooks.453f8858.mjs';
3
3
  import 'url';
4
- import './chunk-mock-date.9160e13b.mjs';
4
+ import './chunk-mock-date.bc81a3ac.mjs';
5
5
  import 'path';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
- import './chunk-runtime-chain.b6c2cdbc.mjs';
8
+ import './chunk-runtime-chain.98d42d89.mjs';
9
9
  import 'util';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.dbf0b31d.mjs';
12
+ import './chunk-runtime-rpc.b50ab560.mjs';
13
13
  import './chunk-utils-global.fa20c2f6.mjs';
14
14
  import './chunk-utils-timers.b48455ed.mjs';
15
15
  import 'fs';
16
- import './chunk-utils-source-map.8198ebd9.mjs';
16
+ import './chunk-utils-source-map.94107ee8.mjs';
17
17
  import './spy.mjs';
18
18
  import 'tinyspy';
19
19
 
@@ -299,18 +299,21 @@ function isFinalObj(obj) {
299
299
  return obj === Object.prototype || obj === Function.prototype || obj === RegExp.prototype;
300
300
  }
301
301
  function collectOwnProperties(obj, collector) {
302
- const props = Object.getOwnPropertyNames(obj);
303
- const symbols = Object.getOwnPropertySymbols(obj);
304
- props.forEach((prop) => collector.add(prop));
305
- symbols.forEach((symbol) => collector.add(symbol));
302
+ const collect = typeof collector === "function" ? collector : (key) => collector.add(key);
303
+ Object.getOwnPropertyNames(obj).forEach(collect);
304
+ Object.getOwnPropertySymbols(obj).forEach(collect);
306
305
  }
307
- function getAllProperties(obj) {
306
+ function getAllMockableProperties(obj) {
308
307
  const allProps = /* @__PURE__ */ new Set();
309
308
  let curr = obj;
310
309
  do {
311
310
  if (isFinalObj(curr))
312
311
  break;
313
- collectOwnProperties(curr, allProps);
312
+ collectOwnProperties(curr, (key) => {
313
+ const descriptor = Object.getOwnPropertyDescriptor(curr, key);
314
+ if (descriptor)
315
+ allProps.add({ key, descriptor });
316
+ });
314
317
  } while (curr = Object.getPrototypeOf(curr));
315
318
  return Array.from(allProps);
316
319
  }
@@ -497,7 +500,7 @@ async function ensurePackageInstalled(dependency, root) {
497
500
  `));
498
501
  if (!promptInstall)
499
502
  return false;
500
- const prompts = await import('./vendor-index.de788b6a.mjs').then(function (n) { return n.i; });
503
+ const prompts = await import('./vendor-index.ae96af6e.mjs').then(function (n) { return n.i; });
501
504
  const { install } = await prompts.prompt({
502
505
  type: "confirm",
503
506
  name: "install",
@@ -549,4 +552,4 @@ class AggregateErrorPonyfill extends Error {
549
552
  }
550
553
  }
551
554
 
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 };
555
+ 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, getAllMockableProperties 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 };
@@ -1,4 +1,4 @@
1
- import { y as resolve } from './chunk-mock-date.9160e13b.mjs';
1
+ import { y as resolve } from './chunk-mock-date.bc81a3ac.mjs';
2
2
  import { Buffer } from 'buffer';
3
3
  import path from 'path';
4
4
  import childProcess from 'child_process';
@@ -1,24 +1,26 @@
1
1
  import util$1 from 'util';
2
- import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, p as picocolors, e as getFullName, n as noop } from './chunk-mock-date.9160e13b.mjs';
2
+ import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, b as getNames, c as assertTypes, p as picocolors, e as getFullName, n as noop } from './chunk-mock-date.bc81a3ac.mjs';
3
3
  import * as chai$2 from 'chai';
4
4
  import { expect, AssertionError, util } from 'chai';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.b50ab560.mjs';
7
7
  import fs, { promises } from 'fs';
8
- import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.8198ebd9.mjs';
8
+ import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.94107ee8.mjs';
9
9
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
10
10
  import { isMockFunction } from './spy.mjs';
11
11
  import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
12
12
 
13
13
  function createChainable(keys, fn) {
14
- function create(obj) {
14
+ function create(context) {
15
15
  const chain2 = function(...args) {
16
- return fn.apply(obj, args);
16
+ return fn.apply(context, args);
17
17
  };
18
+ Object.assign(chain2, fn);
19
+ chain2.withContext = () => chain2.bind(context);
18
20
  for (const key of keys) {
19
21
  Object.defineProperty(chain2, key, {
20
22
  get() {
21
- return create({ ...obj, [key]: true });
23
+ return create({ ...context, [key]: true });
22
24
  }
23
25
  });
24
26
  }
@@ -1233,8 +1235,13 @@ const JestChaiExpect = (chai, utils) => {
1233
1235
  args[0] = args[0].map((key) => key.replace(/([.[\]])/g, "\\$1")).join(".");
1234
1236
  const actual = this._obj;
1235
1237
  const [propertyName, expected] = args;
1236
- const { value, exists } = utils.getPathInfo(actual, propertyName);
1237
- const pass = exists && (args.length === 1 || equals(expected, value));
1238
+ let pass = false;
1239
+ if (Object.prototype.hasOwnProperty.call(actual, propertyName)) {
1240
+ pass = true;
1241
+ } else {
1242
+ const { value, exists } = utils.getPathInfo(actual, propertyName);
1243
+ pass = exists && (args.length === 1 || equals(expected, value));
1244
+ }
1238
1245
  return this.assert(pass, "expected #{this} to have property #{exp}", "expected #{this} to not have property #{exp}", expected, actual);
1239
1246
  });
1240
1247
  def("toBeCloseTo", function(received, precision = 2) {
@@ -2007,11 +2014,12 @@ function createSuiteCollector(name, factory = () => {
2007
2014
  return collector;
2008
2015
  }
2009
2016
  function createSuite() {
2010
- const suite2 = createChainable(["concurrent", "shuffle", "skip", "only", "todo"], function(name, factory) {
2017
+ function suiteFn(name, factory) {
2011
2018
  const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
2012
2019
  return createSuiteCollector(name, factory, mode, this.concurrent, this.shuffle);
2013
- });
2014
- suite2.each = (cases) => {
2020
+ }
2021
+ suiteFn.each = function(cases) {
2022
+ const suite2 = this.withContext();
2015
2023
  return (name, fn) => {
2016
2024
  cases.forEach((i, idx) => {
2017
2025
  const items = Array.isArray(i) ? i : [i];
@@ -2019,23 +2027,24 @@ function createSuite() {
2019
2027
  });
2020
2028
  };
2021
2029
  };
2022
- suite2.skipIf = (condition) => condition ? suite2.skip : suite2;
2023
- suite2.runIf = (condition) => condition ? suite2 : suite2.skip;
2024
- return suite2;
2030
+ suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
2031
+ suiteFn.runIf = (condition) => condition ? suite : suite.skip;
2032
+ return createChainable(["concurrent", "shuffle", "skip", "only", "todo"], suiteFn);
2025
2033
  }
2026
2034
  function createTest(fn) {
2027
- const test2 = createChainable(["concurrent", "skip", "only", "todo", "fails"], fn);
2028
- test2.each = (cases) => {
2029
- return (name, fn2) => {
2035
+ const testFn = fn;
2036
+ testFn.each = function(cases) {
2037
+ const test2 = this.withContext();
2038
+ return (name, fn2, timeout) => {
2030
2039
  cases.forEach((i, idx) => {
2031
2040
  const items = Array.isArray(i) ? i : [i];
2032
- test2(formatTitle(name, items, idx), () => fn2(...items));
2041
+ test2(formatTitle(name, items, idx), () => fn2(...items), timeout);
2033
2042
  });
2034
2043
  };
2035
2044
  };
2036
- test2.skipIf = (condition) => condition ? test2.skip : test2;
2037
- test2.runIf = (condition) => condition ? test2 : test2.skip;
2038
- return test2;
2045
+ testFn.skipIf = (condition) => condition ? test.skip : test;
2046
+ testFn.runIf = (condition) => condition ? test : test.skip;
2047
+ return createChainable(["concurrent", "skip", "only", "todo", "fails"], testFn);
2039
2048
  }
2040
2049
 
2041
2050
  export { GLOBAL_EXPECT as G, getDefaultHookTimeout as a, globalExpect as b, createExpect as c, describe as d, clearCollectorContext as e, defaultSuite as f, getCurrentSuite as g, setHooks as h, it as i, getHooks as j, collectorContext as k, setState as l, getFn as m, getState as n, createSuiteHooks as o, chai$1 as p, suite as s, test as t, withTimeout as w };
@@ -1,11 +1,11 @@
1
- import { e as environments, t as takeCoverage, p as pLimit } from './chunk-defaults.1c51d585.mjs';
2
- import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.3ee34848.mjs';
3
- import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath, q as isBrowser, u as partitionSuiteChildren, v as shuffle, w as hasTests, x as hasFailed, e as getFullName } from './chunk-mock-date.9160e13b.mjs';
4
- import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.b6c2cdbc.mjs';
5
- import { r as rpc } from './chunk-runtime-rpc.dbf0b31d.mjs';
1
+ import { e as environments, t as takeCoverage, p as pLimit } from './chunk-defaults.02abff90.mjs';
2
+ import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.453f8858.mjs';
3
+ import { h as deepClone, k as getType, l as isNode, R as RealDate, t as toArray, o as relativePath, q as isBrowser, u as partitionSuiteChildren, v as shuffle, w as hasTests, x as hasFailed, e as getFullName } from './chunk-mock-date.bc81a3ac.mjs';
4
+ import { e as clearCollectorContext, f as defaultSuite, h as setHooks, j as getHooks, k as collectorContext, l as setState, G as GLOBAL_EXPECT, m as getFn, n as getState } from './chunk-runtime-chain.98d42d89.mjs';
5
+ import { r as rpc } from './chunk-runtime-rpc.b50ab560.mjs';
6
6
  import util$1 from 'util';
7
7
  import { util } from 'chai';
8
- import { s as stringify } from './chunk-utils-source-map.8198ebd9.mjs';
8
+ import { s as stringify } from './chunk-utils-source-map.94107ee8.mjs';
9
9
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
10
10
  import { a as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.b48455ed.mjs';
11
11
 
@@ -123,6 +123,7 @@ async function setupGlobalEnv(config) {
123
123
  value: index,
124
124
  enumerable: false
125
125
  });
126
+ Error.stackTraceLimit = 100;
126
127
  setupDefines(config.defines);
127
128
  if (globalSetup)
128
129
  return;
@@ -130,7 +131,7 @@ async function setupGlobalEnv(config) {
130
131
  if (isNode)
131
132
  await setupConsoleLogSpy();
132
133
  if (config.globals)
133
- (await import('./chunk-integrations-globals.56a11010.mjs')).registerApiGlobally();
134
+ (await import('./chunk-integrations-globals.44a8f047.mjs')).registerApiGlobally();
134
135
  }
135
136
  function setupDefines(defines) {
136
137
  for (const key in defines)
@@ -441,7 +442,7 @@ async function sendTasksUpdate() {
441
442
  async function runTest(test) {
442
443
  var _a, _b;
443
444
  if (test.mode !== "run") {
444
- const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
445
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.98d42d89.mjs').then(function (n) { return n.p; });
445
446
  getSnapshotClient().skipTestSnapshots(test);
446
447
  return;
447
448
  }
@@ -457,7 +458,7 @@ async function runTest(test) {
457
458
  updateTask(test);
458
459
  clearModuleMocks();
459
460
  if (isNode) {
460
- const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
461
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.98d42d89.mjs').then(function (n) { return n.p; });
461
462
  await getSnapshotClient().setTest(test);
462
463
  }
463
464
  const workerState = getWorkerState();
@@ -510,7 +511,7 @@ async function runTest(test) {
510
511
  if (isBrowser && test.result.error)
511
512
  console.error(test.result.error.message, test.result.error.stackStr);
512
513
  if (isNode) {
513
- const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
514
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.98d42d89.mjs').then(function (n) { return n.p; });
514
515
  getSnapshotClient().clearTest();
515
516
  }
516
517
  test.result.duration = now() - start;
@@ -622,7 +623,7 @@ async function startTestsBrowser(paths, config) {
622
623
  async function startTestsNode(paths, config) {
623
624
  const files = await collectTests(paths, config);
624
625
  rpc().onCollected(files);
625
- const { getSnapshotClient } = await import('./chunk-runtime-chain.b6c2cdbc.mjs').then(function (n) { return n.p; });
626
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.98d42d89.mjs').then(function (n) { return n.p; });
626
627
  getSnapshotClient().clear();
627
628
  await runFiles(files, config);
628
629
  takeCoverage();
@@ -1,7 +1,7 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.b6c2cdbc.mjs';
2
- import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.9160e13b.mjs';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, c as createExpect, b as globalExpect } from './chunk-runtime-chain.98d42d89.mjs';
2
+ import { R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.bc81a3ac.mjs';
3
3
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
4
- import { p as parseStacktrace } from './chunk-utils-source-map.8198ebd9.mjs';
4
+ import { p as parseStacktrace } from './chunk-utils-source-map.94107ee8.mjs';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
6
6
  import util from 'util';
7
7
  import { spyOn, fn, isMockFunction, spies } from './spy.mjs';
@@ -2747,7 +2747,7 @@ class VitestUtils {
2747
2747
  async importMock(path) {
2748
2748
  return this._mocker.importMock(path, this.getImporter());
2749
2749
  }
2750
- mocked(item, _deep = false) {
2750
+ mocked(item, _options = {}) {
2751
2751
  return item;
2752
2752
  }
2753
2753
  isMockFunction(fn2) {
@@ -1,9 +1,9 @@
1
- import { V as ViteNodeRunner } from './chunk-vite-node-client.a247c2c2.mjs';
1
+ import { V as ViteNodeRunner } from './chunk-vite-node-client.fdd9592c.mjs';
2
2
  import { normalizePath } from 'vite';
3
- import { M as isWindows, N as mergeSlashes, d as dirname, j as join, z as basename, y as resolve, s as slash, k as getType, O as getAllProperties } from './chunk-mock-date.9160e13b.mjs';
3
+ import { M as isWindows, N as mergeSlashes, d as dirname, j as join, z as basename, y as resolve, s as slash, k as getType, O as getAllMockableProperties } from './chunk-mock-date.bc81a3ac.mjs';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.9dfd1e3f.mjs';
6
- import { d as distDir } from './chunk-constants.16825f0c.mjs';
5
+ import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.f34df9d3.mjs';
6
+ import { d as distDir } from './chunk-constants.26dc9f85.mjs';
7
7
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
8
8
 
9
9
  class RefTracker {
@@ -78,8 +78,22 @@ const _VitestMocker = class {
78
78
  if (cached)
79
79
  return cached;
80
80
  const exports = await mock();
81
+ if (exports === null || typeof exports !== "object")
82
+ throw new Error('[vitest] vi.mock(path: string, factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?');
81
83
  this.moduleCache.set(dep, { exports });
82
- return exports;
84
+ const exportHandler = {
85
+ get(target, prop) {
86
+ const val = target[prop];
87
+ if (prop === "then") {
88
+ if (target instanceof Promise)
89
+ return target.then.bind(target);
90
+ } else if (val === void 0) {
91
+ throw new Error(`[vitest] No "${prop}" export is defined on the "${dep}"`);
92
+ }
93
+ return val;
94
+ }
95
+ };
96
+ return new Proxy(exports, exportHandler);
83
97
  }
84
98
  getMockPath(dep) {
85
99
  return `mock:${dep}`;
@@ -123,13 +137,20 @@ const _VitestMocker = class {
123
137
  const spyModule = _VitestMocker.spyModule;
124
138
  const finalizers = new Array();
125
139
  const refs = new RefTracker();
140
+ const define = (container, key, value) => {
141
+ try {
142
+ container[key] = value;
143
+ return true;
144
+ } catch {
145
+ return false;
146
+ }
147
+ };
126
148
  const mockPropertiesOf = (container, newContainer) => {
127
149
  const containerType = getType(container);
128
150
  const isModule = containerType === "Module" || !!container.__esModule;
129
- for (const property of getAllProperties(container)) {
151
+ for (const { key: property, descriptor } of getAllMockableProperties(container)) {
130
152
  if (!isModule) {
131
- const descriptor = Object.getOwnPropertyDescriptor(container, property);
132
- if ((descriptor == null ? void 0 : descriptor.get) || (descriptor == null ? void 0 : descriptor.set))
153
+ if (descriptor.get || descriptor.set)
133
154
  continue;
134
155
  }
135
156
  if (isSpecialProp(property, containerType))
@@ -137,20 +158,21 @@ const _VitestMocker = class {
137
158
  const value = container[property];
138
159
  const refId = refs.getId(value);
139
160
  if (refId) {
140
- finalizers.push(() => newContainer[property] = refs.getMockedValue(refId));
161
+ finalizers.push(() => define(newContainer, property, refs.getMockedValue(refId)));
141
162
  continue;
142
163
  }
143
164
  const type = getType(value);
144
165
  if (Array.isArray(value)) {
145
- newContainer[property] = [];
166
+ define(newContainer, property, []);
146
167
  continue;
147
168
  }
148
169
  const isFunction = type.includes("Function") && typeof value === "function";
149
170
  if ((!isFunction || value.__isMockFunction) && type !== "Object" && type !== "Module") {
150
- newContainer[property] = value;
171
+ define(newContainer, property, value);
151
172
  continue;
152
173
  }
153
- newContainer[property] = isFunction ? value : {};
174
+ if (!define(newContainer, property, isFunction ? value : {}))
175
+ continue;
154
176
  if (isFunction) {
155
177
  spyModule.spyOn(newContainer, property).mockImplementation(() => void 0);
156
178
  Object.defineProperty(newContainer[property], "length", { value: 0 });
@@ -1,4 +1,4 @@
1
- import './chunk-mock-date.9160e13b.mjs';
1
+ import './chunk-mock-date.bc81a3ac.mjs';
2
2
  import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
3
3
  import { w as withSafeTimers } from './chunk-utils-timers.b48455ed.mjs';
4
4
 
@@ -1,4 +1,4 @@
1
- import { s as slash, f as notNullish, p as picocolors } from './chunk-mock-date.9160e13b.mjs';
1
+ import { s as slash, f as notNullish, p as picocolors } from './chunk-mock-date.bc81a3ac.mjs';
2
2
 
3
3
  var build = {};
4
4
 
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath } from 'url';
3
3
  import vm from 'vm';
4
- import { y as resolve, d as dirname, B as isAbsolute, L as extname } from './chunk-mock-date.9160e13b.mjs';
5
- import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.9dfd1e3f.mjs';
4
+ import { y as resolve, d as dirname, B as isAbsolute, L as extname } from './chunk-mock-date.bc81a3ac.mjs';
5
+ import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.f34df9d3.mjs';
6
6
  import createDebug from 'debug';
7
7
 
8
8
  const debugExecute = createDebug("vite-node:client:execute");
@@ -141,7 +141,11 @@ ${getStack()}`), 2e3);
141
141
  const url = pathToFileURL(fsPath).href;
142
142
  const meta = { url };
143
143
  const exports = /* @__PURE__ */ Object.create(null);
144
- exports[Symbol.toStringTag] = "Module";
144
+ Object.defineProperty(exports, Symbol.toStringTag, {
145
+ value: "Module",
146
+ enumerable: false,
147
+ configurable: false
148
+ });
145
149
  this.moduleCache.set(fsPath, { code: transformed, exports });
146
150
  const __filename = fileURLToPath(url);
147
151
  const moduleProxy = {
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { y as resolve, p as picocolors, j as join } from './chunk-mock-date.9160e13b.mjs';
2
+ import { y as resolve, p as picocolors, j as join } from './chunk-mock-date.bc81a3ac.mjs';
3
3
  import 'path';
4
4
  import 'tty';
5
5
  import 'local-pkg';