@vitest/browser 4.0.0-beta.4 → 4.0.0-beta.6

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.
@@ -23,7 +23,7 @@
23
23
  })();
24
24
  </script>
25
25
  <!-- !LOAD_METADATA! -->
26
- <script type="module" src="./assets/index-YGltZS-e.js"></script>
26
+ <script type="module" src="./assets/index-B3LybwKR.js"></script>
27
27
  <link rel="stylesheet" href="./assets/index-KbpJLW--.css">
28
28
  </head>
29
29
  <body>
@@ -1,8 +1,52 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { g as getDefaultExportFromCjs, a as getBrowserState, b as getConfig, r as relative } from "./utils-BNwnRrZR.js";
4
+ import { g as getDefaultExportFromCjs, a as getBrowserState, b as getConfig, r as relative } from "./utils-FY_Qin7d.js";
5
5
  import { channel, globalChannel, client } from "@vitest/browser/client";
6
+ function toArray(array) {
7
+ if (array === null || array === void 0) {
8
+ array = [];
9
+ }
10
+ if (Array.isArray(array)) {
11
+ return array;
12
+ }
13
+ return [array];
14
+ }
15
+ function isObject(item) {
16
+ return item != null && typeof item === "object" && !Array.isArray(item);
17
+ }
18
+ function objectAttr(source, path, defaultValue = void 0) {
19
+ const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
20
+ let result = source;
21
+ for (const p2 of paths) {
22
+ result = new Object(result)[p2];
23
+ if (result === void 0) {
24
+ return defaultValue;
25
+ }
26
+ }
27
+ return result;
28
+ }
29
+ function createDefer() {
30
+ let resolve2 = null;
31
+ let reject = null;
32
+ const p2 = new Promise((_resolve, _reject) => {
33
+ resolve2 = _resolve;
34
+ reject = _reject;
35
+ });
36
+ p2.resolve = resolve2;
37
+ p2.reject = reject;
38
+ return p2;
39
+ }
40
+ function isNegativeNaN(val) {
41
+ if (!Number.isNaN(val)) {
42
+ return false;
43
+ }
44
+ const f64 = new Float64Array(1);
45
+ f64[0] = val;
46
+ const u32 = new Uint32Array(f64.buffer);
47
+ const isNegative = u32[1] >>> 31 === 1;
48
+ return isNegative;
49
+ }
6
50
  var f = {
7
51
  reset: [0, 0],
8
52
  bold: [1, 22, "\x1B[22m\x1B[1m"],
@@ -381,20 +425,7 @@ function inspectSymbol(value) {
381
425
  }
382
426
  return value.toString();
383
427
  }
384
- let getPromiseValue = () => "Promise{…}";
385
- try {
386
- const { getPromiseDetails, kPending, kRejected } = process.binding("util");
387
- if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
388
- getPromiseValue = (value, options) => {
389
- const [state, innerValue] = getPromiseDetails(value);
390
- if (state === kPending) {
391
- return "Promise{<pending>}";
392
- }
393
- return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
394
- };
395
- }
396
- } catch (notNode) {
397
- }
428
+ const getPromiseValue = () => "Promise{…}";
398
429
  function inspectObject$1(object, options) {
399
430
  const properties = Object.getOwnPropertyNames(object);
400
431
  const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
@@ -730,50 +761,6 @@ function objDisplay(obj, options = {}) {
730
761
  }
731
762
  return str;
732
763
  }
733
- function toArray(array) {
734
- if (array === null || array === void 0) {
735
- array = [];
736
- }
737
- if (Array.isArray(array)) {
738
- return array;
739
- }
740
- return [array];
741
- }
742
- function isObject(item) {
743
- return item != null && typeof item === "object" && !Array.isArray(item);
744
- }
745
- function objectAttr(source, path, defaultValue = void 0) {
746
- const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
747
- let result = source;
748
- for (const p2 of paths) {
749
- result = new Object(result)[p2];
750
- if (result === void 0) {
751
- return defaultValue;
752
- }
753
- }
754
- return result;
755
- }
756
- function createDefer() {
757
- let resolve2 = null;
758
- let reject = null;
759
- const p2 = new Promise((_resolve, _reject) => {
760
- resolve2 = _resolve;
761
- reject = _reject;
762
- });
763
- p2.resolve = resolve2;
764
- p2.reject = reject;
765
- return p2;
766
- }
767
- function isNegativeNaN(val) {
768
- if (!Number.isNaN(val)) {
769
- return false;
770
- }
771
- const f64 = new Float64Array(1);
772
- f64[0] = val;
773
- const u32 = new Uint32Array(f64.buffer);
774
- const isNegative = u32[1] >>> 31 === 1;
775
- return isNegative;
776
- }
777
764
  var jsTokens_1$1;
778
765
  var hasRequiredJsTokens$1;
779
766
  function requireJsTokens$1() {
@@ -1712,24 +1699,6 @@ function stripLiteral(code, options) {
1712
1699
  function stripLiteralDetailed(code, options) {
1713
1700
  return stripLiteralJsTokens(code);
1714
1701
  }
1715
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1716
- const intToChar = new Uint8Array(64);
1717
- const charToInt = new Uint8Array(128);
1718
- for (let i = 0; i < chars.length; i++) {
1719
- const c = chars.charCodeAt(i);
1720
- intToChar[i] = c;
1721
- charToInt[c] = i;
1722
- }
1723
- var UrlType;
1724
- (function(UrlType2) {
1725
- UrlType2[UrlType2["Empty"] = 1] = "Empty";
1726
- UrlType2[UrlType2["Hash"] = 2] = "Hash";
1727
- UrlType2[UrlType2["Query"] = 3] = "Query";
1728
- UrlType2[UrlType2["RelativePath"] = 4] = "RelativePath";
1729
- UrlType2[UrlType2["AbsolutePath"] = 5] = "AbsolutePath";
1730
- UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
1731
- UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
1732
- })(UrlType || (UrlType = {}));
1733
1702
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
1734
1703
  function normalizeWindowsPath(input = "") {
1735
1704
  if (!input) {
@@ -1825,6 +1794,24 @@ function normalizeString(path, allowAboveRoot) {
1825
1794
  const isAbsolute = function(p2) {
1826
1795
  return _IS_ABSOLUTE_RE.test(p2);
1827
1796
  };
1797
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1798
+ const intToChar = new Uint8Array(64);
1799
+ const charToInt = new Uint8Array(128);
1800
+ for (let i = 0; i < chars.length; i++) {
1801
+ const c = chars.charCodeAt(i);
1802
+ intToChar[i] = c;
1803
+ charToInt[c] = i;
1804
+ }
1805
+ var UrlType;
1806
+ (function(UrlType2) {
1807
+ UrlType2[UrlType2["Empty"] = 1] = "Empty";
1808
+ UrlType2[UrlType2["Hash"] = 2] = "Hash";
1809
+ UrlType2[UrlType2["Query"] = 3] = "Query";
1810
+ UrlType2[UrlType2["RelativePath"] = 4] = "RelativePath";
1811
+ UrlType2[UrlType2["AbsolutePath"] = 5] = "AbsolutePath";
1812
+ UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
1813
+ UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
1814
+ })(UrlType || (UrlType = {}));
1828
1815
  const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m;
1829
1816
  const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/;
1830
1817
  function extractLocation(urlLike) {
@@ -2286,8 +2273,7 @@ function createSuiteHooks() {
2286
2273
  }
2287
2274
  function parseArguments(optionsOrFn, optionsOrTest) {
2288
2275
  let options = {};
2289
- let fn = () => {
2290
- };
2276
+ let fn;
2291
2277
  if (typeof optionsOrTest === "object") {
2292
2278
  if (typeof optionsOrFn === "object") {
2293
2279
  throw new TypeError("Cannot use two objects as arguments. Please provide options and a function callback in that order.");
@@ -2337,6 +2323,9 @@ function createSuiteCollector(name, factory = () => {
2337
2323
  annotations: []
2338
2324
  };
2339
2325
  const handler = options.handler;
2326
+ if (task2.mode === "run" && !handler) {
2327
+ task2.mode = "todo";
2328
+ }
2340
2329
  if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
2341
2330
  task2.concurrent = true;
2342
2331
  }
@@ -2468,9 +2457,12 @@ function withAwaitAsyncAssertions(fn, task) {
2468
2457
  function createSuite() {
2469
2458
  function suiteFn(name, factoryOrOptions, optionsOrFactory) {
2470
2459
  var _currentSuite$options;
2471
- const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
2460
+ let mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
2472
2461
  const currentSuite = collectorContext.currentSuite || defaultSuite;
2473
2462
  let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
2463
+ if (mode === "run" && !factory) {
2464
+ mode = "todo";
2465
+ }
2474
2466
  const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
2475
2467
  const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
2476
2468
  options = {
@@ -2499,15 +2491,15 @@ function createSuite() {
2499
2491
  const items = Array.isArray(i) ? i : [i];
2500
2492
  if (fnFirst) {
2501
2493
  if (arrayOnlyCases) {
2502
- suite2(formatTitle(_name, items, idx), () => handler(...items), options);
2494
+ suite2(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options);
2503
2495
  } else {
2504
- suite2(formatTitle(_name, items, idx), () => handler(i), options);
2496
+ suite2(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options);
2505
2497
  }
2506
2498
  } else {
2507
2499
  if (arrayOnlyCases) {
2508
- suite2(formatTitle(_name, items, idx), options, () => handler(...items));
2500
+ suite2(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2509
2501
  } else {
2510
- suite2(formatTitle(_name, items, idx), options, () => handler(i));
2502
+ suite2(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
2511
2503
  }
2512
2504
  }
2513
2505
  });
@@ -2522,7 +2514,7 @@ function createSuite() {
2522
2514
  const name_ = formatName(name);
2523
2515
  const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2524
2516
  cases.forEach((item, idx) => {
2525
- suite(formatTitle(name_, toArray(item), idx), options, () => handler(item));
2517
+ suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : void 0);
2526
2518
  });
2527
2519
  };
2528
2520
  };
@@ -2554,15 +2546,15 @@ function createTaskCollector(fn, context) {
2554
2546
  const items = Array.isArray(i) ? i : [i];
2555
2547
  if (fnFirst) {
2556
2548
  if (arrayOnlyCases) {
2557
- test(formatTitle(_name, items, idx), () => handler(...items), options);
2549
+ test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options);
2558
2550
  } else {
2559
- test(formatTitle(_name, items, idx), () => handler(i), options);
2551
+ test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options);
2560
2552
  }
2561
2553
  } else {
2562
2554
  if (arrayOnlyCases) {
2563
- test(formatTitle(_name, items, idx), options, () => handler(...items));
2555
+ test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2564
2556
  } else {
2565
- test(formatTitle(_name, items, idx), options, () => handler(i));
2557
+ test(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
2566
2558
  }
2567
2559
  }
2568
2560
  });
@@ -2578,9 +2570,11 @@ function createTaskCollector(fn, context) {
2578
2570
  const _name = formatName(name);
2579
2571
  const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2580
2572
  cases.forEach((item, idx) => {
2581
- const handlerWrapper = (ctx) => handler(item, ctx);
2582
- handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
2583
- handlerWrapper.toString = () => handler.toString();
2573
+ const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
2574
+ if (handlerWrapper) {
2575
+ handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
2576
+ handlerWrapper.toString = () => handler.toString();
2577
+ }
2584
2578
  test(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
2585
2579
  });
2586
2580
  };
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { g as getDefaultExportFromCjs$1, c as resolve, e as executor, d as getWorkerState, b as getConfig, a as getBrowserState } from "./utils-BNwnRrZR.js";
4
+ import { g as getDefaultExportFromCjs$1, c as resolve, m as moduleRunner, d as getWorkerState, b as getConfig, a as getBrowserState } from "./utils-FY_Qin7d.js";
5
5
  import { onCancel, globalChannel, channel, client } from "@vitest/browser/client";
6
6
  import { userEvent, page, server } from "@vitest/browser/context";
7
7
  import { getSafeTimers, TraceMap as TraceMap$1, originalPositionFor as originalPositionFor$1, loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, stringify, format, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, startTests, collectTests, SpyModule } from "vitest/internal/browser";
@@ -1001,6 +1001,8 @@ const stackIgnorePatterns = [
1001
1001
  "/node_modules/chai/",
1002
1002
  "/node_modules/tinypool/",
1003
1003
  "/node_modules/tinyspy/",
1004
+ "/vite/dist/node/module-runner",
1005
+ "/rolldown-vite/dist/node/module-runner",
1004
1006
  // browser related deps
1005
1007
  "/deps/chunk-",
1006
1008
  "/deps/@vitest",
@@ -1280,7 +1282,7 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
1280
1282
  await rpc$2().onAfterSuiteRun({
1281
1283
  coverage,
1282
1284
  testFiles: files.map((file) => file.name),
1283
- transformMode: "browser",
1285
+ environment: "__browser__",
1284
1286
  projectName: this.config.name
1285
1287
  });
1286
1288
  }
@@ -1366,7 +1368,7 @@ async function initiateRunner(state, mocker, config) {
1366
1368
  }
1367
1369
  const runnerClass = config.mode === "test" ? VitestTestRunner : NodeBenchmarkRunner;
1368
1370
  const BrowserRunner = createBrowserRunner(runnerClass, mocker, state, {
1369
- takeCoverage: () => takeCoverageInsideWorker(config.coverage, executor)
1371
+ takeCoverage: () => takeCoverageInsideWorker(config.coverage, moduleRunner)
1370
1372
  });
1371
1373
  if (!config.snapshotOptions.snapshotEnvironment) {
1372
1374
  config.snapshotOptions.snapshotEnvironment = new VitestBrowserSnapshotEnvironment();
@@ -1380,8 +1382,8 @@ async function initiateRunner(state, mocker, config) {
1380
1382
  (_a = runner.cancel) == null ? void 0 : _a.call(runner, reason);
1381
1383
  });
1382
1384
  const [diffOptions] = await Promise.all([
1383
- loadDiffConfig(config, executor),
1384
- loadSnapshotSerializers(config, executor)
1385
+ loadDiffConfig(config, moduleRunner),
1386
+ loadSnapshotSerializers(config, moduleRunner)
1385
1387
  ]);
1386
1388
  runner.config.diffOptions = diffOptions;
1387
1389
  getWorkerState().onFilterStackTrace = (stack) => {
@@ -1626,6 +1628,9 @@ class MockerRegistry {
1626
1628
  delete(id) {
1627
1629
  this.registryByUrl.delete(id);
1628
1630
  }
1631
+ deleteById(id) {
1632
+ this.registryById.delete(id);
1633
+ }
1629
1634
  get(id) {
1630
1635
  return this.registryByUrl.get(id);
1631
1636
  }
@@ -1744,18 +1749,42 @@ function mockObject(options, object2, mockExports = {}) {
1744
1749
  return false;
1745
1750
  }
1746
1751
  };
1752
+ const createMock = (currentValue) => {
1753
+ if (!options.createMockInstance) {
1754
+ throw new Error("[@vitest/mocker] `createMockInstance` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
1755
+ }
1756
+ const createMockInstance = options.createMockInstance;
1757
+ const prototypeMembers = currentValue.prototype ? collectFunctionProperties(currentValue.prototype) : [];
1758
+ return createMockInstance({
1759
+ name: currentValue.name,
1760
+ prototypeMembers,
1761
+ originalImplementation: options.type === "autospy" ? currentValue : void 0,
1762
+ keepMembersImplementation: options.type === "autospy"
1763
+ });
1764
+ };
1747
1765
  const mockPropertiesOf = (container, newContainer) => {
1748
1766
  const containerType = getType(container);
1749
1767
  const isModule = containerType === "Module" || !!container.__esModule;
1750
1768
  for (const { key: property, descriptor } of getAllMockableProperties(container, isModule, options.globalConstructors)) {
1751
1769
  if (!isModule && descriptor.get) {
1752
1770
  try {
1753
- Object.defineProperty(newContainer, property, descriptor);
1771
+ if (options.type === "autospy") {
1772
+ Object.defineProperty(newContainer, property, descriptor);
1773
+ } else {
1774
+ Object.defineProperty(newContainer, property, {
1775
+ configurable: descriptor.configurable,
1776
+ enumerable: descriptor.enumerable,
1777
+ get: () => {
1778
+ },
1779
+ set: descriptor.set ? () => {
1780
+ } : void 0
1781
+ });
1782
+ }
1754
1783
  } catch {
1755
1784
  }
1756
1785
  continue;
1757
1786
  }
1758
- if (isSpecialProp(property, containerType)) {
1787
+ if (isReadonlyProp(container[property], property)) {
1759
1788
  continue;
1760
1789
  }
1761
1790
  const value = container[property];
@@ -1766,7 +1795,22 @@ function mockObject(options, object2, mockExports = {}) {
1766
1795
  }
1767
1796
  const type = getType(value);
1768
1797
  if (Array.isArray(value)) {
1769
- define(newContainer, property, []);
1798
+ if (options.type === "automock") {
1799
+ define(newContainer, property, []);
1800
+ } else {
1801
+ const array = value.map((value2) => {
1802
+ if (value2 && typeof value2 === "object") {
1803
+ const newObject = {};
1804
+ mockPropertiesOf(value2, newObject);
1805
+ return newObject;
1806
+ }
1807
+ if (typeof value2 === "function") {
1808
+ return createMock(value2);
1809
+ }
1810
+ return value2;
1811
+ });
1812
+ define(newContainer, property, array);
1813
+ }
1770
1814
  continue;
1771
1815
  }
1772
1816
  const isFunction = type.includes("Function") && typeof value === "function";
@@ -1774,47 +1818,12 @@ function mockObject(options, object2, mockExports = {}) {
1774
1818
  define(newContainer, property, value);
1775
1819
  continue;
1776
1820
  }
1777
- if (!define(newContainer, property, isFunction ? value : {})) {
1821
+ if (!define(newContainer, property, isFunction || options.type === "autospy" ? value : {})) {
1778
1822
  continue;
1779
1823
  }
1780
1824
  if (isFunction) {
1781
- let mockFunction = function() {
1782
- if (this instanceof newContainer[property]) {
1783
- for (const { key, descriptor: descriptor2 } of getAllMockableProperties(this, false, options.globalConstructors)) {
1784
- if (descriptor2.get) {
1785
- continue;
1786
- }
1787
- const value2 = this[key];
1788
- const type2 = getType(value2);
1789
- const isFunction2 = type2.includes("Function") && typeof value2 === "function";
1790
- if (isFunction2) {
1791
- const original = this[key];
1792
- const mock2 = spyOn(this, key).mockImplementation(original);
1793
- const origMockReset = mock2.mockReset;
1794
- mock2.mockRestore = mock2.mockReset = () => {
1795
- origMockReset.call(mock2);
1796
- mock2.mockImplementation(original);
1797
- return mock2;
1798
- };
1799
- }
1800
- }
1801
- }
1802
- };
1803
- if (!options.spyOn) {
1804
- throw new Error("[@vitest/mocker] `spyOn` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
1805
- }
1806
- const spyOn = options.spyOn;
1807
- const mock = spyOn(newContainer, property);
1808
- if (options.type === "automock") {
1809
- mock.mockImplementation(mockFunction);
1810
- const origMockReset = mock.mockReset;
1811
- mock.mockRestore = mock.mockReset = () => {
1812
- origMockReset.call(mock);
1813
- mock.mockImplementation(mockFunction);
1814
- return mock;
1815
- };
1816
- }
1817
- Object.defineProperty(newContainer[property], "length", { value: 0 });
1825
+ const mock = createMock(newContainer[property]);
1826
+ newContainer[property] = mock;
1818
1827
  }
1819
1828
  refs.track(value, newContainer[property]);
1820
1829
  mockPropertiesOf(value, newContainer[property]);
@@ -1848,14 +1857,15 @@ class RefTracker {
1848
1857
  function getType(value) {
1849
1858
  return Object.prototype.toString.apply(value).slice(8, -1);
1850
1859
  }
1851
- function isSpecialProp(prop, parentType) {
1852
- return parentType.includes("Function") && typeof prop === "string" && [
1853
- "arguments",
1854
- "callee",
1855
- "caller",
1856
- "length",
1857
- "name"
1858
- ].includes(prop);
1860
+ function isReadonlyProp(object2, prop) {
1861
+ if (prop === "arguments" || prop === "caller" || prop === "callee" || prop === "name" || prop === "length") {
1862
+ const typeName = getType(object2);
1863
+ return typeName === "Function" || typeName === "AsyncFunction" || typeName === "GeneratorFunction" || typeName === "AsyncGeneratorFunction";
1864
+ }
1865
+ if (prop === "source" || prop === "global" || prop === "ignoreCase" || prop === "multiline") {
1866
+ return getType(object2) === "RegExp";
1867
+ }
1868
+ return false;
1859
1869
  }
1860
1870
  function getAllMockableProperties(obj, isModule, constructors) {
1861
1871
  const { Map: Map2, Object: Object2, Function: Function2, RegExp: RegExp2, Array: Array2 } = constructors;
@@ -1891,6 +1901,20 @@ function collectOwnProperties(obj, collector) {
1891
1901
  Object.getOwnPropertyNames(obj).forEach(collect);
1892
1902
  Object.getOwnPropertySymbols(obj).forEach(collect);
1893
1903
  }
1904
+ function collectFunctionProperties(prototype) {
1905
+ const properties = /* @__PURE__ */ new Set();
1906
+ collectOwnProperties(prototype, (prop) => {
1907
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
1908
+ if (!descriptor || descriptor.get) {
1909
+ return;
1910
+ }
1911
+ const type = getType(descriptor.value);
1912
+ if (type.includes("Function") && !isReadonlyProp(descriptor.value, prop)) {
1913
+ properties.add(prop);
1914
+ }
1915
+ });
1916
+ return Array.from(properties);
1917
+ }
1894
1918
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
1895
1919
  function normalizeWindowsPath(input = "") {
1896
1920
  if (!input) {
@@ -2373,20 +2397,6 @@ const reactIsMethods = [
2373
2397
  "isValidElementType"
2374
2398
  ];
2375
2399
  Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
2376
- let getPromiseValue = () => "Promise{…}";
2377
- try {
2378
- const { getPromiseDetails, kPending, kRejected } = process.binding("util");
2379
- if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
2380
- getPromiseValue = (value, options) => {
2381
- const [state, innerValue] = getPromiseDetails(value);
2382
- if (state === kPending) {
2383
- return "Promise{<pending>}";
2384
- }
2385
- return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
2386
- };
2387
- }
2388
- } catch (notNode) {
2389
- }
2390
2400
  var jsTokens_1;
2391
2401
  var hasRequiredJsTokens;
2392
2402
  function requireJsTokens() {
@@ -2851,13 +2861,13 @@ var UrlType;
2851
2861
  })(UrlType || (UrlType = {}));
2852
2862
  const { now } = Date;
2853
2863
  class ModuleMocker {
2854
- constructor(interceptor, rpc2, spyOn, config) {
2864
+ constructor(interceptor, rpc2, createMockInstance, config) {
2855
2865
  __publicField(this, "registry", new MockerRegistry());
2856
2866
  __publicField(this, "queue", /* @__PURE__ */ new Set());
2857
2867
  __publicField(this, "mockedIds", /* @__PURE__ */ new Set());
2858
2868
  this.interceptor = interceptor;
2859
2869
  this.rpc = rpc2;
2860
- this.spyOn = spyOn;
2870
+ this.createMockInstance = createMockInstance;
2861
2871
  this.config = config;
2862
2872
  }
2863
2873
  async prepare() {
@@ -2955,7 +2965,7 @@ class ModuleMocker {
2955
2965
  Map,
2956
2966
  RegExp
2957
2967
  },
2958
- spyOn: this.spyOn,
2968
+ createMockInstance: this.createMockInstance,
2959
2969
  type: moduleType
2960
2970
  }, object2);
2961
2971
  }
@@ -3082,6 +3092,7 @@ class CommandsManager {
3082
3092
  });
3083
3093
  }
3084
3094
  }
3095
+ const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false, "VITE_TEST_WATCHER_DEBUG": "false" };
3085
3096
  const debugVar = getConfig().env.VITEST_BROWSER_DEBUG;
3086
3097
  const debug = debugVar && debugVar !== "false" ? (...args) => {
3087
3098
  var _a, _b;
@@ -3093,7 +3104,7 @@ channel.addEventListener("message", async (e) => {
3093
3104
  debug == null ? void 0 : debug("event from orchestrator", JSON.stringify(e.data));
3094
3105
  if (!isEvent(data)) {
3095
3106
  const error = new Error(`Unknown message: ${JSON.stringify(e.data)}`);
3096
- unhandledError(error, "Uknown Iframe Message");
3107
+ unhandledError(error, "Unknown Iframe Message");
3097
3108
  return;
3098
3109
  }
3099
3110
  if (!("iframeId" in data) || data.iframeId !== getBrowserState().iframeId) {
@@ -3128,7 +3139,7 @@ channel.addEventListener("message", async (e) => {
3128
3139
  }
3129
3140
  default: {
3130
3141
  const error = new Error(`Unknown event: ${data.event}`);
3131
- unhandledError(error, "Uknown Event");
3142
+ unhandledError(error, "Unknown Event");
3132
3143
  }
3133
3144
  }
3134
3145
  channel.postMessage({
@@ -3148,13 +3159,14 @@ async function prepareTestEnvironment(options) {
3148
3159
  const config = getConfig();
3149
3160
  const rpc2 = createSafeRpc(client);
3150
3161
  const state = getWorkerState();
3162
+ state.metaEnv = __vite_import_meta_env__;
3151
3163
  state.onCancel = onCancel;
3152
3164
  state.rpc = rpc2;
3153
3165
  const interceptor = createModuleMockerInterceptor();
3154
3166
  const mocker = new VitestBrowserClientMocker(
3155
3167
  interceptor,
3156
3168
  rpc2,
3157
- SpyModule.spyOn,
3169
+ SpyModule.createMockInstance,
3158
3170
  {
3159
3171
  root: getBrowserState().viteConfig.root
3160
3172
  }
@@ -3220,7 +3232,7 @@ async function prepare(options) {
3220
3232
  debug == null ? void 0 : debug("prepare time", state.durations.prepare, "ms");
3221
3233
  await Promise.all([
3222
3234
  setupCommonEnv(config),
3223
- startCoverageInsideWorker(config.coverage, executor, { isolate: config.browser.isolate }),
3235
+ startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }),
3224
3236
  (async () => {
3225
3237
  const VitestIndex = await __vitePreload(() => import("vitest"), true ? [] : void 0);
3226
3238
  Object.defineProperty(window, "__vitest_index__", {
@@ -3250,7 +3262,7 @@ async function cleanup() {
3250
3262
  await rpc2.wdioSwitchContext("parent").catch((error) => unhandledError(error, "Cleanup Error"));
3251
3263
  }
3252
3264
  state.environmentTeardownRun = true;
3253
- await stopCoverageInsideWorker(config.coverage, executor, { isolate: config.browser.isolate }).catch((error) => {
3265
+ await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }).catch((error) => {
3254
3266
  return unhandledError(error, "Coverage Error");
3255
3267
  });
3256
3268
  }
@@ -164,9 +164,9 @@ async function importFs(id) {
164
164
  name
165
165
  ));
166
166
  }
167
- const executor = {
167
+ const moduleRunner = {
168
168
  isBrowser: true,
169
- executeId: (id) => {
169
+ import: (id) => {
170
170
  if (id[0] === "/" || id[1] === ":") {
171
171
  return importFs(id);
172
172
  }
@@ -193,7 +193,7 @@ export {
193
193
  getConfig as b,
194
194
  resolve as c,
195
195
  getWorkerState as d,
196
- executor as e,
197
196
  getDefaultExportFromCjs as g,
197
+ moduleRunner as m,
198
198
  relative as r
199
199
  };
@@ -26,8 +26,8 @@
26
26
  {__VITEST_INJECTOR__}
27
27
  {__VITEST_ERROR_CATCHER__}
28
28
  {__VITEST_SCRIPTS__}
29
- <script type="module" crossorigin src="/__vitest_browser__/orchestrator-BXzaDpYw.js"></script>
30
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-BNwnRrZR.js">
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-C2rrmv36.js"></script>
30
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-FY_Qin7d.js">
31
31
  </head>
32
32
  <body>
33
33
  <div id="vitest-tester"></div>
@@ -5,8 +5,8 @@
5
5
  <link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vitest Browser Tester</title>
8
- <script type="module" crossorigin src="/__vitest_browser__/tester-DabNvcOf.js"></script>
9
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-BNwnRrZR.js">
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-DSNROWDQ.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-FY_Qin7d.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>