@vitest/browser-playwright 4.1.0-beta.4 → 4.1.0-beta.5

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 (2) hide show
  1. package/dist/index.js +21 -13
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -799,17 +799,6 @@ class PlaywrightBrowserProvider {
799
799
  this.browserPromise = (async () => {
800
800
  const options = this.project.config.browser;
801
801
  const playwright = await import('playwright');
802
- if (this.options.connectOptions) {
803
- if (this.options.launchOptions) {
804
- this.project.vitest.logger.warn(c.yellow(`Found both ${c.bold(c.italic(c.yellow("connect")))} and ${c.bold(c.italic(c.yellow("launch")))} options in browser instance configuration.
805
- Ignoring ${c.bold(c.italic(c.yellow("launch")))} options and using ${c.bold(c.italic(c.yellow("connect")))} mode.
806
- You probably want to remove one of the two options and keep only the one you want to use.`));
807
- }
808
- const browser = await playwright[this.browserName].connect(this.options.connectOptions.wsEndpoint, this.options.connectOptions);
809
- this.browser = browser;
810
- this.browserPromise = null;
811
- return this.browser;
812
- }
813
802
  const launchOptions = {
814
803
  ...this.options.launchOptions,
815
804
  headless: options.headless
@@ -824,8 +813,10 @@ class PlaywrightBrowserProvider {
824
813
  const host = inspector.host || "127.0.0.1";
825
814
  launchOptions.args ||= [];
826
815
  launchOptions.args.push(`--remote-debugging-port=${port}`);
827
- launchOptions.args.push(`--remote-debugging-address=${host}`);
828
- this.project.vitest.logger.log(`Debugger listening on ws://${host}:${port}`);
816
+ if (host !== "localhost" && host !== "127.0.0.1" && host !== "::1") {
817
+ this.project.vitest.logger.warn(`Custom inspector host "${host}" will be ignored. Chromium only allows remote debugging on localhost.`);
818
+ }
819
+ this.project.vitest.logger.log(`Debugger listening on ws://127.0.0.1:${port}`);
829
820
  }
830
821
  // start Vitest UI maximized only on supported browsers
831
822
  if (this.project.config.browser.ui && this.browserName === "chromium") {
@@ -837,6 +828,23 @@ class PlaywrightBrowserProvider {
837
828
  }
838
829
  }
839
830
  debug?.("[%s] initializing the browser with launch options: %O", this.browserName, launchOptions);
831
+ if (this.options.connectOptions) {
832
+ let { wsEndpoint, headers = {}, ...connectOptions } = this.options.connectOptions;
833
+ if ("x-playwright-launch-options" in headers) {
834
+ this.project.vitest.logger.warn(c.yellow("Detected \"x-playwright-launch-options\" in connectOptions.headers. Provider config launchOptions is ignored."));
835
+ } else {
836
+ headers = {
837
+ ...headers,
838
+ "x-playwright-launch-options": JSON.stringify(launchOptions)
839
+ };
840
+ }
841
+ this.browser = await playwright[this.browserName].connect(wsEndpoint, {
842
+ ...connectOptions,
843
+ headers
844
+ });
845
+ this.browserPromise = null;
846
+ return this.browser;
847
+ }
840
848
  let persistentContextOption = this.options.persistentContext;
841
849
  if (persistentContextOption && openBrowserOptions.parallel) {
842
850
  persistentContextOption = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/browser-playwright",
3
3
  "type": "module",
4
- "version": "4.1.0-beta.4",
4
+ "version": "4.1.0-beta.5",
5
5
  "description": "Browser running for Vitest using playwright",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -42,7 +42,7 @@
42
42
  ],
43
43
  "peerDependencies": {
44
44
  "playwright": "*",
45
- "vitest": "4.1.0-beta.4"
45
+ "vitest": "4.1.0-beta.5"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "playwright": {
@@ -51,12 +51,12 @@
51
51
  },
52
52
  "dependencies": {
53
53
  "tinyrainbow": "^3.0.3",
54
- "@vitest/browser": "4.1.0-beta.4",
55
- "@vitest/mocker": "4.1.0-beta.4"
54
+ "@vitest/browser": "4.1.0-beta.5",
55
+ "@vitest/mocker": "4.1.0-beta.5"
56
56
  },
57
57
  "devDependencies": {
58
- "playwright": "^1.58.1",
59
- "vitest": "4.1.0-beta.4"
58
+ "playwright": "^1.58.2",
59
+ "vitest": "4.1.0-beta.5"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "premove dist && pnpm rollup -c",