@vitest/browser 3.0.0 → 3.0.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.
@@ -23,7 +23,7 @@
23
23
  })();
24
24
  </script>
25
25
  <!-- !LOAD_METADATA! -->
26
- <script type="module" src="./assets/index-DnuP8DQO.js"></script>
26
+ <script type="module" src="./assets/index-D9z-wtyx.js"></script>
27
27
  <link rel="stylesheet" href="./assets/index-GEF0wBOB.css">
28
28
  </head>
29
29
  <body>
@@ -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 getBrowserState, a as getConfig, r as relative } from "./utils-CaCTRFti.js";
4
+ import { g as getBrowserState, a as getConfig, r as relative } from "./utils-Owv5OOOf.js";
5
5
  import { client, channel, globalChannel } from "@vitest/browser/client";
6
6
  function generateHash(str) {
7
7
  let hash = 0;
@@ -1,8 +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
- var _a2;
5
- import { a as getConfig, g as getBrowserState, b as resolve, e as executor, c as getWorkerState } from "./utils-CaCTRFti.js";
4
+ import { a as getConfig, g as getBrowserState, b as resolve, e as executor, c as getWorkerState } from "./utils-Owv5OOOf.js";
6
5
  import { globalChannel, client, onCancel, channel } from "@vitest/browser/client";
7
6
  import { userEvent, page } from "@vitest/browser/context";
8
7
  import { loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, setupCommonEnv, startCoverageInsideWorker, startTests, collectTests, stopCoverageInsideWorker, SpyModule } from "vitest/browser";
@@ -10296,7 +10295,7 @@ function toHaveAccessibleDescription(htmlElement, expectedAccessibleDescription)
10296
10295
  const ariaInvalidName = "aria-invalid";
10297
10296
  const validStates = ["false"];
10298
10297
  function toHaveAccessibleErrorMessage(htmlElement, expectedAccessibleErrorMessage) {
10299
- var _a3;
10298
+ var _a;
10300
10299
  checkHtmlElement(htmlElement, toHaveAccessibleErrorMessage, this);
10301
10300
  const to = this.isNot ? "not to" : "to";
10302
10301
  const method = this.isNot ? ".not.toHaveAccessibleErrorMessage" : ".toHaveAccessibleErrorMessage";
@@ -10335,7 +10334,7 @@ function toHaveAccessibleErrorMessage(htmlElement, expectedAccessibleErrorMessag
10335
10334
  };
10336
10335
  }
10337
10336
  const error = normalize$1(
10338
- ((_a3 = htmlElement.ownerDocument.getElementById(errormessageId)) == null ? void 0 : _a3.textContent) ?? ""
10337
+ ((_a = htmlElement.ownerDocument.getElementById(errormessageId)) == null ? void 0 : _a.textContent) ?? ""
10339
10338
  );
10340
10339
  return {
10341
10340
  pass: expectedAccessibleErrorMessage === void 0 ? Boolean(error) : expectedAccessibleErrorMessage instanceof RegExp ? expectedAccessibleErrorMessage.test(error) : this.equals(error, expectedAccessibleErrorMessage),
@@ -11079,8 +11078,8 @@ function supportedRoles() {
11079
11078
  return roles_1.keys().filter(roleSupportsChecked);
11080
11079
  }
11081
11080
  function roleSupportsChecked(role) {
11082
- var _a3;
11083
- return ((_a3 = roles_1.get(role)) == null ? void 0 : _a3.props["aria-checked"]) !== void 0;
11081
+ var _a;
11082
+ return ((_a = roles_1.get(role)) == null ? void 0 : _a.props["aria-checked"]) !== void 0;
11084
11083
  }
11085
11084
  function toBePartiallyChecked(element) {
11086
11085
  checkHtmlElement(element, toBePartiallyChecked, this);
@@ -11409,11 +11408,11 @@ function setupConsoleLogSpy() {
11409
11408
  sendLog("stdout", processLog(args));
11410
11409
  };
11411
11410
  console$1.trace = (...args) => {
11412
- var _a3;
11411
+ var _a;
11413
11412
  trace(...args);
11414
11413
  const content = processLog(args);
11415
11414
  const error2 = new Error("$$Trace");
11416
- const processor = ((_a3 = globalThis.__vitest_worker__) == null ? void 0 : _a3.onFilterStackTrace) || ((s) => s || "");
11415
+ const processor = ((_a = globalThis.__vitest_worker__) == null ? void 0 : _a.onFilterStackTrace) || ((s) => s || "");
11417
11416
  const stack = processor(error2.stack || "");
11418
11417
  sendLog("stderr", `${content}
11419
11418
  ${stack}`, true);
@@ -11480,12 +11479,12 @@ function processLog(args) {
11480
11479
  return args.map(formatInput).join(" ");
11481
11480
  }
11482
11481
  function sendLog(type, content, disableStack) {
11483
- var _a3, _b, _c;
11482
+ var _a, _b, _c;
11484
11483
  if (content.startsWith("[vite]")) {
11485
11484
  return;
11486
11485
  }
11487
11486
  const unknownTestId = "__vitest__unknown_test__";
11488
- const taskId = ((_b = (_a3 = globalThis.__vitest_worker__) == null ? void 0 : _a3.current) == null ? void 0 : _b.id) ?? unknownTestId;
11487
+ const taskId = ((_b = (_a = globalThis.__vitest_worker__) == null ? void 0 : _a.current) == null ? void 0 : _b.id) ?? unknownTestId;
11489
11488
  const origin = getConfig().printConsoleTrace && !disableStack ? (_c = new Error("STACK_TRACE").stack) == null ? void 0 : _c.split("\n").slice(1).join("\n") : void 0;
11490
11489
  rpc$1().sendLog({
11491
11490
  origin,
@@ -11837,7 +11836,6 @@ const _UNC_REGEX = /^[/\\]{2}/;
11837
11836
  const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
11838
11837
  const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
11839
11838
  const _EXTNAME_RE = /.(\.[^./]+)$/;
11840
- ((_a2 = globalThis.process) == null ? void 0 : _a2.platform) === "win32" ? ";" : ":";
11841
11839
  const normalize = function(path) {
11842
11840
  if (path.length === 0) {
11843
11841
  return ".";
@@ -11955,7 +11953,6 @@ const extname = function(p) {
11955
11953
  const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
11956
11954
  return match && match[1] || "";
11957
11955
  };
11958
- var _a;
11959
11956
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
11960
11957
  const intToChar = new Uint8Array(64);
11961
11958
  const charToInt = new Uint8Array(128);
@@ -11974,7 +11971,6 @@ var UrlType;
11974
11971
  UrlType2[UrlType2["SchemeRelative"] = 6] = "SchemeRelative";
11975
11972
  UrlType2[UrlType2["Absolute"] = 7] = "Absolute";
11976
11973
  })(UrlType || (UrlType = {}));
11977
- ((_a = globalThis.process) == null ? void 0 : _a.platform) === "win32" ? ";" : ":";
11978
11974
  const { now } = Date;
11979
11975
  class ModuleMocker {
11980
11976
  constructor(interceptor, rpc2, spyOn, config) {
@@ -13182,13 +13178,13 @@ function requireResolveUri_umd() {
13182
13178
  return map;
13183
13179
  }
13184
13180
  function encodedMappings(map) {
13185
- var _a3;
13181
+ var _a;
13186
13182
  var _b;
13187
- return (_a3 = (_b = cast(map))._encoded) !== null && _a3 !== void 0 ? _a3 : _b._encoded = sourcemapCodec.encode(cast(map)._decoded);
13183
+ return (_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : _b._encoded = sourcemapCodec.encode(cast(map)._decoded);
13188
13184
  }
13189
13185
  function decodedMappings(map) {
13190
- var _a3;
13191
- return (_a3 = cast(map))._decoded || (_a3._decoded = sourcemapCodec.decode(cast(map)._encoded));
13186
+ var _a;
13187
+ return (_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded));
13192
13188
  }
13193
13189
  function traceSegment(map, line, column) {
13194
13190
  const decoded = decodedMappings(map);
@@ -13335,7 +13331,7 @@ function requireResolveUri_umd() {
13335
13331
  return result;
13336
13332
  }
13337
13333
  function generatedPosition(map, source2, line, column, bias, all) {
13338
- var _a3;
13334
+ var _a;
13339
13335
  line--;
13340
13336
  if (line < 0)
13341
13337
  throw new Error(LINE_GTR_ZERO);
@@ -13347,7 +13343,7 @@ function requireResolveUri_umd() {
13347
13343
  sourceIndex2 = resolvedSources.indexOf(source2);
13348
13344
  if (sourceIndex2 === -1)
13349
13345
  return all ? [] : GMapping(null, null);
13350
- const generated = (_a3 = cast(map))._bySources || (_a3._bySources = buildBySources(decodedMappings(map), cast(map)._bySourceMemos = sources.map(memoizedState)));
13346
+ const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), cast(map)._bySourceMemos = sources.map(memoizedState)));
13351
13347
  const segments = generated[sourceIndex2][line];
13352
13348
  if (segments == null)
13353
13349
  return all ? [] : GMapping(null, null);
@@ -13512,11 +13508,11 @@ function parseStacktrace(stack, options = {}) {
13512
13508
  );
13513
13509
  }
13514
13510
  return stacks.map((stack2) => {
13515
- var _a3;
13511
+ var _a;
13516
13512
  if (options.getFileName) {
13517
13513
  stack2.file = options.getFileName(stack2.file);
13518
13514
  }
13519
- const map = (_a3 = options.getSourceMap) == null ? void 0 : _a3.call(options, stack2.file);
13515
+ const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
13520
13516
  if (!map || typeof map !== "object" || !map.version) {
13521
13517
  return stack2;
13522
13518
  }
@@ -13592,13 +13588,13 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
13592
13588
  __publicField(this, "hashMap", browserHashMap);
13593
13589
  __publicField(this, "sourceMapCache", /* @__PURE__ */ new Map());
13594
13590
  __publicField(this, "onBeforeTryTask", async (...args) => {
13595
- var _a3;
13591
+ var _a;
13596
13592
  await userEvent.cleanup();
13597
- await ((_a3 = super.onBeforeTryTask) == null ? void 0 : _a3.call(this, ...args));
13593
+ await ((_a = super.onBeforeTryTask) == null ? void 0 : _a.call(this, ...args));
13598
13594
  });
13599
13595
  __publicField(this, "onAfterRunTask", async (task) => {
13600
- var _a3, _b;
13601
- await ((_a3 = super.onAfterRunTask) == null ? void 0 : _a3.call(this, task));
13596
+ var _a, _b;
13597
+ await ((_a = super.onAfterRunTask) == null ? void 0 : _a.call(this, task));
13602
13598
  if (this.config.bail && ((_b = task.result) == null ? void 0 : _b.state) === "fail") {
13603
13599
  const previousFailures = await rpc$1().getCountOfFailedTests();
13604
13600
  const currentFailures = 1 + previousFailures;
@@ -13609,8 +13605,8 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
13609
13605
  }
13610
13606
  });
13611
13607
  __publicField(this, "onTaskFinished", async (task) => {
13612
- var _a3;
13613
- if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((_a3 = task.result) == null ? void 0 : _a3.state) === "fail") {
13608
+ var _a;
13609
+ if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((_a = task.result) == null ? void 0 : _a.state) === "fail") {
13614
13610
  const screenshot = await page.screenshot().catch((err) => {
13615
13611
  console.error("[vitest] Failed to take a screenshot", err);
13616
13612
  });
@@ -13620,14 +13616,14 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
13620
13616
  }
13621
13617
  });
13622
13618
  __publicField(this, "onCancel", (reason) => {
13623
- var _a3;
13624
- (_a3 = super.onCancel) == null ? void 0 : _a3.call(this, reason);
13619
+ var _a;
13620
+ (_a = super.onCancel) == null ? void 0 : _a.call(this, reason);
13625
13621
  globalChannel.postMessage({ type: "cancel", reason });
13626
13622
  });
13627
13623
  __publicField(this, "onBeforeRunSuite", async (suite) => {
13628
- var _a3;
13624
+ var _a;
13629
13625
  await Promise.all([
13630
- (_a3 = super.onBeforeRunSuite) == null ? void 0 : _a3.call(this, suite),
13626
+ (_a = super.onBeforeRunSuite) == null ? void 0 : _a.call(this, suite),
13631
13627
  (async () => {
13632
13628
  if ("filepath" in suite) {
13633
13629
  const map = await rpc$1().getBrowserFileSourceMap(suite.filepath);
@@ -13641,9 +13637,9 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
13641
13637
  ]);
13642
13638
  });
13643
13639
  __publicField(this, "onAfterRunFiles", async (files) => {
13644
- var _a3, _b;
13640
+ var _a, _b;
13645
13641
  const [coverage] = await Promise.all([
13646
- (_a3 = coverageModule == null ? void 0 : coverageModule.takeCoverage) == null ? void 0 : _a3.call(coverageModule),
13642
+ (_a = coverageModule == null ? void 0 : coverageModule.takeCoverage) == null ? void 0 : _a.call(coverageModule),
13647
13643
  mocker.invalidate(),
13648
13644
  (_b = super.onAfterRunFiles) == null ? void 0 : _b.call(this, files)
13649
13645
  ]);
@@ -13788,8 +13784,8 @@ async function prepareTestEnvironment(files) {
13788
13784
  }
13789
13785
  });
13790
13786
  onCancel.then((reason) => {
13791
- var _a3;
13792
- (_a3 = runner.onCancel) == null ? void 0 : _a3.call(runner, reason);
13787
+ var _a;
13788
+ (_a = runner.onCancel) == null ? void 0 : _a.call(runner, reason);
13793
13789
  });
13794
13790
  return {
13795
13791
  runner,
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  (function polyfill() {
3
2
  const relList = document.createElement("link").relList;
4
3
  if (relList && relList.supports && relList.supports("modulepreload")) {
@@ -45,7 +44,6 @@ function normalizeWindowsPath(input = "") {
45
44
  }
46
45
  const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
47
46
  const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
48
- ((_a = globalThis.process) == null ? void 0 : _a.platform) === "win32" ? ";" : ":";
49
47
  function cwd() {
50
48
  if (typeof process !== "undefined" && typeof process.cwd === "function") {
51
49
  return process.cwd().replace(/\\/g, "/");
@@ -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-Cv-bzUFk.js"></script>
30
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-CaCTRFti.js">
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-vOivV83Y.js"></script>
30
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.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-B8eJg1-s.js"></script>
9
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-CaCTRFti.js">
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-COSVU_mu.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
package/dist/client.js CHANGED
@@ -28,7 +28,7 @@ function createBirpc(functions, options) {
28
28
  if (method === "$close")
29
29
  return close;
30
30
  if (method === "then" && !eventNames.includes("then") && !("then" in functions))
31
- return void 0;
31
+ return undefined;
32
32
  const sendEvent = (...args) => {
33
33
  post(serialize({ m: method, a: args, t: "q" }));
34
34
  };
@@ -43,7 +43,7 @@ function createBirpc(functions, options) {
43
43
  try {
44
44
  await _promise;
45
45
  } finally {
46
- _promise = void 0;
46
+ _promise = undefined;
47
47
  }
48
48
  }
49
49
  return new Promise((resolve, reject) => {
@@ -202,7 +202,7 @@ const parse = (text, reviver) => {
202
202
  */
203
203
  const stringify = (value, replacer, space) => {
204
204
  const $ = typeof replacer === object ?
205
- (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
205
+ (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : undefined) :
206
206
  (replacer);
207
207
  const known = new Map;
208
208
  const input = [];
package/dist/context.js CHANGED
@@ -114,7 +114,7 @@ function getParent(el) {
114
114
  const state = () => getWorkerState();
115
115
  const provider = __vitest_browser_runner__.provider;
116
116
  function filepath() {
117
- return getWorkerState().filepath || getWorkerState().current?.file?.filepath || void 0;
117
+ return getWorkerState().filepath || getWorkerState().current?.file?.filepath || undefined;
118
118
  }
119
119
  const rpc = () => getWorkerState().rpc;
120
120
  const sessionId = getBrowserState().sessionId;
@@ -342,7 +342,7 @@ const page = {
342
342
  const name = options.path || `${taskName.replace(/[^a-z0-9]/gi, "-")}-${number}.png`;
343
343
  return ensureAwaited(() => triggerCommand("__vitest_screenshot", name, {
344
344
  ...options,
345
- element: options.element ? convertToSelector(options.element) : void 0
345
+ element: options.element ? convertToSelector(options.element) : undefined
346
346
  }));
347
347
  },
348
348
  getByRole() {
@@ -1,5 +1,5 @@
1
1
  import { server, page } from '@vitest/browser/context';
2
- import { I as Ivya, a as getByRoleSelector, c as getByAltTextSelector, g as getByLabelSelector, d as getByPlaceholderSelector, b as getByTestIdSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from './public-utils-D6S2-5kI.js';
2
+ import { I as Ivya, a as getByRoleSelector, c as getByAltTextSelector, g as getByLabelSelector, d as getByPlaceholderSelector, b as getByTestIdSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from './public-utils-DldpEzVw.js';
3
3
 
4
4
  function ensureAwaited(promise) {
5
5
  const test = (/* @__PURE__ */ getWorkerState()).current;
@@ -260,7 +260,7 @@ class Locator {
260
260
  return this.worker.rpc;
261
261
  }
262
262
  triggerCommand(command, ...args) {
263
- const filepath = this.worker.filepath || this.worker.current?.file?.filepath || void 0;
263
+ const filepath = this.worker.filepath || this.worker.current?.file?.filepath || undefined;
264
264
  return ensureAwaited(() => this.rpc.triggerCommand(
265
265
  this.state.sessionId,
266
266
  command,