@vitest/browser 2.2.0-beta.1 → 2.2.0-beta.2

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,8 +23,8 @@
23
23
  })();
24
24
  </script>
25
25
  <!-- !LOAD_METADATA! -->
26
- <script type="module" src="./assets/index-DWjHzG4O.js"></script>
27
- <link rel="stylesheet" href="./assets/index-CGSAdLIf.css">
26
+ <script type="module" src="./assets/index-XquuyCWh.js"></script>
27
+ <link rel="stylesheet" href="./assets/index-CVf0zraX.css">
28
28
  </head>
29
29
  <body>
30
30
  <div id="app"></div>
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vitest/config';
2
- import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, WorkspaceProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node';
2
+ import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, TestProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node';
3
3
  import * as vitest from 'vitest';
4
4
  import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff } from 'vitest';
5
5
  import { HtmlTagDescriptor } from 'vite';
@@ -90,7 +90,7 @@ declare class BrowserServerState implements BrowserServerState$1 {
90
90
  }
91
91
 
92
92
  declare class BrowserServer implements BrowserServer$1 {
93
- project: WorkspaceProject;
93
+ project: TestProject;
94
94
  base: string;
95
95
  faviconUrl: string;
96
96
  prefixTesterUrl: string;
@@ -108,7 +108,7 @@ declare class BrowserServer implements BrowserServer$1 {
108
108
  provider: BrowserProvider;
109
109
  vite: Vite.ViteDevServer;
110
110
  private stackTraceOptions;
111
- constructor(project: WorkspaceProject, base: string);
111
+ constructor(project: TestProject, base: string);
112
112
  setServer(server: Vite.ViteDevServer): void;
113
113
  getSerializableConfig(): SerializedConfig;
114
114
  resolveTesterUrl(pathname: string): {
@@ -128,6 +128,6 @@ declare const distRoot: string;
128
128
 
129
129
  declare function createBrowserPool(ctx: Vitest): ProcessPool;
130
130
 
131
- declare function createBrowserServer(project: WorkspaceProject, configFile: string | undefined, prePlugins?: Plugin[], postPlugins?: Plugin[]): Promise<BrowserServer>;
131
+ declare function createBrowserServer(project: TestProject, configFile: string | undefined, prePlugins?: Plugin[], postPlugins?: Plugin[]): Promise<BrowserServer>;
132
132
 
133
133
  export { BrowserServer, createBrowserPool, createBrowserServer, distRoot };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import MagicString from 'magic-string';
8
8
  import sirv from 'sirv';
9
9
  import { coverageConfigDefaults } from 'vitest/config';
10
10
  import { fileURLToPath } from 'node:url';
11
- import { P as PlaywrightBrowserProvider, W as WebdriverBrowserProvider } from './webdriver-Cv9wga63.js';
11
+ import { P as PlaywrightBrowserProvider, W as WebdriverBrowserProvider } from './webdriver-D0J8HSNX.js';
12
12
  import { resolve as resolve$1, dirname as dirname$1, basename as basename$1, normalize as normalize$1 } from 'node:path';
13
13
  import { mkdir, readFile as readFile$1 } from 'node:fs/promises';
14
14
  import crypto from 'node:crypto';
@@ -16,7 +16,7 @@ import { WebSocketServer } from 'ws';
16
16
  import { parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map';
17
17
  import * as nodeos from 'node:os';
18
18
 
19
- var version = "2.2.0-beta.1";
19
+ var version = "2.2.0-beta.2";
20
20
 
21
21
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
22
22
  function normalizeWindowsPath(input = "") {
@@ -385,7 +385,7 @@ _Mime_extensionToType = new WeakMap(), _Mime_typeToExtension = new WeakMap(), _M
385
385
  var mime = new Mime(types)._freeze();
386
386
 
387
387
  function assertFileAccess(path, project) {
388
- if (!isFileServingAllowed(path, project.server) && !isFileServingAllowed(path, project.ctx.server)) {
388
+ if (!isFileServingAllowed(path, project.vite) && !isFileServingAllowed(path, project.vitest.server)) {
389
389
  throw new Error(
390
390
  `Access denied to "${path}". See Vite config documentation for "server.fs": https://vitejs.dev/config/server-options.html#server-fs-strict.`
391
391
  );
@@ -2644,9 +2644,9 @@ function createBrowserPool(ctx) {
2644
2644
  };
2645
2645
  const runWorkspaceTests = async (method, specs) => {
2646
2646
  const groupedFiles = /* @__PURE__ */ new Map();
2647
- for (const [project, file] of specs) {
2647
+ for (const { project, moduleId } of specs) {
2648
2648
  const files = groupedFiles.get(project) || [];
2649
- files.push(file);
2649
+ files.push(moduleId);
2650
2650
  groupedFiles.set(project, files);
2651
2651
  }
2652
2652
  let isCancelled = false;
@@ -2657,7 +2657,7 @@ function createBrowserPool(ctx) {
2657
2657
  if (isCancelled) {
2658
2658
  break;
2659
2659
  }
2660
- await project.initBrowserProvider();
2660
+ await project._initBrowserProvider();
2661
2661
  await executeTests(method, project, files);
2662
2662
  }
2663
2663
  };
package/dist/providers.js CHANGED
@@ -1,4 +1,4 @@
1
- import { W as WebdriverBrowserProvider, P as PlaywrightBrowserProvider } from './webdriver-Cv9wga63.js';
1
+ import { W as WebdriverBrowserProvider, P as PlaywrightBrowserProvider } from './webdriver-D0J8HSNX.js';
2
2
 
3
3
  class PreviewBrowserProvider {
4
4
  name = "preview";
@@ -4,7 +4,7 @@ class PlaywrightBrowserProvider {
4
4
  supportsParallelism = true;
5
5
  browser = null;
6
6
  browserName;
7
- ctx;
7
+ project;
8
8
  options;
9
9
  contexts = /* @__PURE__ */ new Map();
10
10
  pages = /* @__PURE__ */ new Map();
@@ -13,7 +13,7 @@ class PlaywrightBrowserProvider {
13
13
  return playwrightBrowsers;
14
14
  }
15
15
  initialize(project, { browser, options }) {
16
- this.ctx = project;
16
+ this.project = project;
17
17
  this.browserName = browser;
18
18
  this.options = options;
19
19
  }
@@ -25,21 +25,21 @@ class PlaywrightBrowserProvider {
25
25
  return this.browser;
26
26
  }
27
27
  this.browserPromise = (async () => {
28
- const options = this.ctx.config.browser;
28
+ const options = this.project.config.browser;
29
29
  const playwright = await import('playwright');
30
30
  const launchOptions = {
31
31
  ...this.options?.launch,
32
32
  headless: options.headless
33
33
  };
34
- if (this.ctx.config.inspector.enabled) {
35
- const port = this.ctx.config.inspector.port || 9229;
36
- const host = this.ctx.config.inspector.host || "127.0.0.1";
34
+ if (this.project.config.inspector.enabled) {
35
+ const port = this.project.config.inspector.port || 9229;
36
+ const host = this.project.config.inspector.host || "127.0.0.1";
37
37
  launchOptions.args ||= [];
38
38
  launchOptions.args.push(`--remote-debugging-port=${port}`);
39
39
  launchOptions.args.push(`--remote-debugging-address=${host}`);
40
- this.ctx.logger.log(`Debugger listening on ws://${host}:${port}`);
40
+ this.project.logger.log(`Debugger listening on ws://${host}:${port}`);
41
41
  }
42
- if (this.ctx.config.browser.ui && this.browserName === "chromium") {
42
+ if (this.project.config.browser.ui && this.browserName === "chromium") {
43
43
  if (!launchOptions.args) {
44
44
  launchOptions.args = [];
45
45
  }
@@ -64,7 +64,7 @@ class PlaywrightBrowserProvider {
64
64
  ignoreHTTPSErrors: true,
65
65
  serviceWorkers: "allow"
66
66
  };
67
- if (this.ctx.config.browser.ui) {
67
+ if (this.project.config.browser.ui) {
68
68
  options.viewport = null;
69
69
  }
70
70
  const context = await browser.newContext(options);
@@ -168,13 +168,13 @@ class WebdriverBrowserProvider {
168
168
  supportsParallelism = false;
169
169
  browser = null;
170
170
  browserName;
171
- ctx;
171
+ project;
172
172
  options;
173
173
  getSupportedBrowsers() {
174
174
  return webdriverBrowsers;
175
175
  }
176
176
  async initialize(ctx, { browser, options }) {
177
- this.ctx = ctx;
177
+ this.project = ctx;
178
178
  this.browserName = browser;
179
179
  this.options = options;
180
180
  }
@@ -198,7 +198,7 @@ class WebdriverBrowserProvider {
198
198
  if (this.browser) {
199
199
  return this.browser;
200
200
  }
201
- const options = this.ctx.config.browser;
201
+ const options = this.project.config.browser;
202
202
  if (this.browserName === "safari") {
203
203
  if (options.headless) {
204
204
  throw new Error(
@@ -224,7 +224,7 @@ class WebdriverBrowserProvider {
224
224
  firefox: ["moz:firefoxOptions", ["-headless"]],
225
225
  edge: ["ms:edgeOptions", ["--headless"]]
226
226
  };
227
- const options = this.ctx.config.browser;
227
+ const options = this.project.config.browser;
228
228
  const browser = this.browserName;
229
229
  if (browser !== "safari" && options.headless) {
230
230
  const [key, args] = headlessMap[browser];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser",
3
3
  "type": "module",
4
- "version": "2.2.0-beta.1",
4
+ "version": "2.2.0-beta.2",
5
5
  "description": "Browser running for Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -62,7 +62,7 @@
62
62
  "peerDependencies": {
63
63
  "playwright": "*",
64
64
  "webdriverio": "*",
65
- "vitest": "2.2.0-beta.1"
65
+ "vitest": "2.2.0-beta.2"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "playwright": {
@@ -83,8 +83,8 @@
83
83
  "sirv": "^3.0.0",
84
84
  "tinyrainbow": "^1.2.0",
85
85
  "ws": "^8.18.0",
86
- "@vitest/mocker": "2.2.0-beta.1",
87
- "@vitest/utils": "2.2.0-beta.1"
86
+ "@vitest/mocker": "2.2.0-beta.2",
87
+ "@vitest/utils": "2.2.0-beta.2"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@testing-library/jest-dom": "^6.6.3",
@@ -100,10 +100,10 @@
100
100
  "playwright-core": "^1.48.2",
101
101
  "safaridriver": "^0.1.2",
102
102
  "webdriverio": "^8.40.6",
103
- "@vitest/runner": "2.2.0-beta.1",
104
- "@vitest/ui": "2.2.0-beta.1",
105
- "@vitest/ws-client": "2.2.0-beta.1",
106
- "vitest": "2.2.0-beta.1"
103
+ "@vitest/runner": "2.2.0-beta.2",
104
+ "vitest": "2.2.0-beta.2",
105
+ "@vitest/ui": "2.2.0-beta.2",
106
+ "@vitest/ws-client": "2.2.0-beta.2"
107
107
  },
108
108
  "scripts": {
109
109
  "build": "rimraf dist && pnpm build:node && pnpm build:client",