@vitest/browser 3.0.5 → 3.0.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.
@@ -26,7 +26,7 @@
26
26
  {__VITEST_INJECTOR__}
27
27
  {__VITEST_ERROR_CATCHER__}
28
28
  {__VITEST_SCRIPTS__}
29
- <script type="module" crossorigin src="/__vitest_browser__/orchestrator-vOivV83Y.js"></script>
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-BR1Ueh0Q.js"></script>
30
30
  <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
31
31
  </head>
32
32
  <body>
@@ -5,7 +5,7 @@
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-BbJOQDQr.js"></script>
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-oUsZBBvV.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
10
10
  </head>
11
11
  <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 undefined;
31
+ return void 0;
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 = undefined;
46
+ _promise = void 0;
47
47
  }
48
48
  }
49
49
  return new Promise((resolve, reject) => {
@@ -201,9 +201,9 @@ const parse = (text, reviver) => {
201
201
  * @returns {string}
202
202
  */
203
203
  const stringify = (value, replacer, space) => {
204
- const $ = typeof replacer === object ?
205
- (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : undefined) :
206
- (replacer);
204
+ const $ = replacer && typeof replacer === object ?
205
+ (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
206
+ (replacer || noop);
207
207
  const known = new Map;
208
208
  const input = [];
209
209
  const output = [];
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 || undefined;
117
+ return getWorkerState().filepath || getWorkerState().current?.file?.filepath || void 0;
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) : undefined
345
+ element: options.element ? convertToSelector(options.element) : void 0
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-DldpEzVw.js';
2
+ import { I as Ivya, e as getByRoleSelector, c as getByAltTextSelector, f as getByLabelSelector, b as getByPlaceholderSelector, d as getByTestIdSelector, a as getByTextSelector, g as getByTitleSelector, h as getElementError } from './public-utils-J4vwTaki.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 || undefined;
263
+ const filepath = this.worker.filepath || this.worker.current?.file?.filepath || void 0;
264
264
  return ensureAwaited(() => this.rpc.triggerCommand(
265
265
  this.state.sessionId,
266
266
  command,
package/dist/index.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { Plugin } from 'vitest/config';
2
2
  import { CDPSession, BrowserServerState as BrowserServerState$1, ProjectBrowser as ProjectBrowser$1, TestProject, BrowserProvider, Vitest, ResolvedConfig, Vite, BrowserCommand, BrowserScript, ProcessPool } from 'vitest/node';
3
- import * as vite from 'vite';
4
- import { HtmlTagDescriptor } from 'vite';
5
- import * as vitest from 'vitest';
6
- import { RunnerTestFile, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
3
+ import { ViteDevServer, HtmlTagDescriptor } from 'vite';
4
+ import { CancelReason, RunnerTestFile, AfterSuiteRunMeta, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
7
5
  import { StackTraceParserOptions } from '@vitest/utils/source-map';
8
6
  import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
9
7
  import { TaskResultPack, TaskEventPack } from '@vitest/runner';
@@ -100,11 +98,11 @@ declare class ProjectBrowser implements ProjectBrowser$1 {
100
98
  parent: ParentBrowserProject;
101
99
  state: BrowserServerState;
102
100
  constructor(project: TestProject, base: string);
103
- get vite(): vite.ViteDevServer;
101
+ get vite(): ViteDevServer;
104
102
  wrapSerializedConfig(): SerializedConfig;
105
103
  initBrowserProvider(project: TestProject): Promise<void>;
106
- parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): vitest.ParsedStack[];
107
- parseStacktrace(trace: string, options?: StackTraceParserOptions): vitest.ParsedStack[];
104
+ parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
105
+ parseStacktrace(trace: string, options?: StackTraceParserOptions): ParsedStack[];
108
106
  close(): Promise<void>;
109
107
  }
110
108
 
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { resolve as resolve$1, dirname as dirname$1, basename as basename$1, nor
16
16
  import { WebSocketServer } from 'ws';
17
17
  import * as nodeos from 'node:os';
18
18
 
19
- var version = "3.0.5";
19
+ var version = "3.0.6";
20
20
 
21
21
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
22
22
  function normalizeWindowsPath(input = "") {
@@ -417,7 +417,7 @@ const parse = (text, reviver) => {
417
417
  */
418
418
  const stringify = (value, replacer, space) => {
419
419
  const $ = replacer && typeof replacer === object ?
420
- (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : undefined) :
420
+ (k, v) => (k === '' || -1 < replacer.indexOf(k) ? v : void 0) :
421
421
  (replacer || noop);
422
422
  const known = new Map;
423
423
  const input = [];
@@ -627,7 +627,7 @@ var BrowserPlugin = (parentServer, base = "/") => {
627
627
  }
628
628
  );
629
629
  const coverageFolder = resolveCoverageFolder(parentServer.vitest);
630
- const coveragePath = coverageFolder ? coverageFolder[1] : undefined;
630
+ const coveragePath = coverageFolder ? coverageFolder[1] : void 0;
631
631
  if (coveragePath && base === coveragePath) {
632
632
  throw new Error(
633
633
  `The ui base path and the coverage path cannot be the same: ${base}, change coverage.reportsDirectory`
@@ -1069,7 +1069,7 @@ function tryResolve(path, paths) {
1069
1069
  const _require2 = getRequire();
1070
1070
  return _require2.resolve(path, { paths });
1071
1071
  } catch {
1072
- return undefined;
1072
+ return void 0;
1073
1073
  }
1074
1074
  }
1075
1075
  let _require;
@@ -1086,15 +1086,15 @@ function resolveCoverageFolder(vitest) {
1086
1086
  return reporter === "html";
1087
1087
  }
1088
1088
  return reporter[0] === "html";
1089
- }) : undefined;
1089
+ }) : void 0;
1090
1090
  if (!htmlReporter) {
1091
- return undefined;
1091
+ return void 0;
1092
1092
  }
1093
1093
  const root = resolve(
1094
1094
  options.root || process.cwd(),
1095
1095
  options.coverage.reportsDirectory || coverageConfigDefaults.reportsDirectory
1096
1096
  );
1097
- const subdir = Array.isArray(htmlReporter) && htmlReporter.length > 1 && "subdir" in htmlReporter[1] ? htmlReporter[1].subdir : undefined;
1097
+ const subdir = Array.isArray(htmlReporter) && htmlReporter.length > 1 && "subdir" in htmlReporter[1] ? htmlReporter[1].subdir : void 0;
1098
1098
  if (!subdir || typeof subdir !== "string") {
1099
1099
  return [root, `/${basename(root)}/`];
1100
1100
  }
@@ -2464,7 +2464,7 @@ function wrapConfig(config) {
2464
2464
  return {
2465
2465
  ...config,
2466
2466
  // workaround RegExp serialization
2467
- testNamePattern: config.testNamePattern ? config.testNamePattern.toString() : undefined
2467
+ testNamePattern: config.testNamePattern ? config.testNamePattern.toString() : void 0
2468
2468
  };
2469
2469
  }
2470
2470
 
@@ -2617,7 +2617,7 @@ class ParentBrowserProject {
2617
2617
  const server = this.vite;
2618
2618
  const promises = scripts.map(
2619
2619
  async ({ content, src, async, id, type = "module" }, index) => {
2620
- const srcLink = (src ? (await server.pluginContainer.resolveId(src))?.id : undefined) || src;
2620
+ const srcLink = (src ? (await server.pluginContainer.resolveId(src))?.id : void 0) || src;
2621
2621
  const transformId = srcLink || join(server.config.root, `virtual__${id || `injected-${index}.js`}`);
2622
2622
  await server.moduleGraph.ensureEntryFromUrl(transformId);
2623
2623
  const contentProcessed = content && type === "module" ? (await server.pluginContainer.transform(content, transformId)).code : content;
@@ -2674,7 +2674,7 @@ function createBirpc(functions, options) {
2674
2674
  if (method === "$close")
2675
2675
  return close;
2676
2676
  if (method === "then" && !eventNames.includes("then") && !("then" in functions))
2677
- return undefined;
2677
+ return void 0;
2678
2678
  const sendEvent = (...args) => {
2679
2679
  post(serialize({ m: method, a: args, t: "q" }));
2680
2680
  };
@@ -2689,7 +2689,7 @@ function createBirpc(functions, options) {
2689
2689
  try {
2690
2690
  await _promise;
2691
2691
  } finally {
2692
- _promise = undefined;
2692
+ _promise = void 0;
2693
2693
  }
2694
2694
  }
2695
2695
  return new Promise((resolve, reject) => {
@@ -3131,6 +3131,9 @@ function createBrowserPool(vitest) {
3131
3131
  if (!config.fileParallelism) {
3132
3132
  return 1;
3133
3133
  }
3134
+ if (project.config.maxWorkers) {
3135
+ return project.config.maxWorkers;
3136
+ }
3134
3137
  return vitest.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
3135
3138
  }
3136
3139
  return {
@@ -1,4 +1,4 @@
1
1
  import '@vitest/browser/context';
2
- import '../public-utils-DldpEzVw.js';
3
- export { L as Locator, s as selectorEngine } from '../index--cbQOwRJ.js';
2
+ import '../public-utils-J4vwTaki.js';
3
+ export { L as Locator, s as selectorEngine } from '../index-D-kNWeee.js';
4
4
  import 'vitest/utils';
@@ -1,6 +1,6 @@
1
1
  import { page, server } from '@vitest/browser/context';
2
- import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector } from '../public-utils-DldpEzVw.js';
3
- import { s as selectorEngine, L as Locator } from '../index--cbQOwRJ.js';
2
+ import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector } from '../public-utils-J4vwTaki.js';
3
+ import { s as selectorEngine, L as Locator } from '../index-D-kNWeee.js';
4
4
  import 'vitest/utils';
5
5
 
6
6
  page.extend({
@@ -1,6 +1,6 @@
1
1
  import { page, server, userEvent } from '@vitest/browser/context';
2
- import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from '../public-utils-DldpEzVw.js';
3
- import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index--cbQOwRJ.js';
2
+ import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-J4vwTaki.js';
3
+ import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-D-kNWeee.js';
4
4
  import 'vitest/utils';
5
5
 
6
6
  page.extend({
@@ -1,6 +1,6 @@
1
1
  import { page, server } from '@vitest/browser/context';
2
- import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from '../public-utils-DldpEzVw.js';
3
- import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index--cbQOwRJ.js';
2
+ import { g as getByTitleSelector, a as getByTextSelector, b as getByPlaceholderSelector, c as getByAltTextSelector, d as getByTestIdSelector, e as getByRoleSelector, f as getByLabelSelector, h as getElementError } from '../public-utils-J4vwTaki.js';
3
+ import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-D-kNWeee.js';
4
4
  import 'vitest/utils';
5
5
 
6
6
  page.extend({