Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@
]
},
{
"name": "Launch Playwright on Codespaces VS Code Extension",
"name": "Launch Playwright Local Browser Server VS Code Extension",
"type": "extensionHost",
"request": "launch",
"cwd": "${workspaceFolder}/vscode-extensions/playwright-on-codespaces-vscode-extension/dist/vsix/unpacked",
"cwd": "${workspaceFolder}/vscode-extensions/playwright-local-browser-server-vscode-extension/dist/vsix/unpacked",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/playwright-on-codespaces-vscode-extension/dist/vsix/unpacked"
"--extensionDevelopmentPath=${workspaceFolder}/vscode-extensions/playwright-local-browser-server-vscode-extension/dist/vsix/unpacked"
],
"sourceMaps": true,
"outFiles": [
"${workspaceFolder}/vscode-extensions/playwright-on-codespaces-vscode-extension/**/*.js"
"${workspaceFolder}/vscode-extensions/playwright-local-browser-server-vscode-extension/**/*.js"
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/rigs/local-web-rig](./rigs/local-web-rig/) | A rig package for Web projects that build using Heft inside the RushStack repository. |
| [/rush-plugins/rush-litewatch-plugin](./rush-plugins/rush-litewatch-plugin/) | An experimental alternative approach for multi-project watch mode |
| [/vscode-extensions/debug-certificate-manager-vscode-extension](./vscode-extensions/debug-certificate-manager-vscode-extension/) | VS Code extension to manage debug TLS certificates and sync them to the VS Code workspace. Works with VS Code remote development (Codespaces, SSH, Dev Containers, WSL, VS Code Tunnels). |
| [/vscode-extensions/playwright-on-codespaces-vscode-extension](./vscode-extensions/playwright-on-codespaces-vscode-extension/) | VS Code extension to enable Playwright testing in GitHub Codespaces. |
| [/vscode-extensions/playwright-local-browser-server-vscode-extension](./vscode-extensions/playwright-local-browser-server-vscode-extension/) | VS Code extension to enable Playwright testing in remote VS Code environments (such as Codespaces, Dev Containers, VS Code Tunnels) while launching and driving the actual browser process on your local machine. |
| [/vscode-extensions/rush-vscode-command-webview](./vscode-extensions/rush-vscode-command-webview/) | Part of the Rush Stack VSCode extension, provides a UI for invoking Rush commands |
| [/vscode-extensions/rush-vscode-extension](./vscode-extensions/rush-vscode-extension/) | Enhanced experience for monorepos that use the Rush Stack toolchain |
| [/vscode-extensions/vscode-shared](./vscode-extensions/vscode-shared/) | |
Expand Down
20 changes: 10 additions & 10 deletions apps/playwright-browser-tunnel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ Run a Playwright browser server in one environment and drive it from another env

This package is intended for remote development / CI scenarios (for example: Codespaces, devcontainers, or a separate “browser host” machine) where you want tests to run “here” but the actual browser process to run “there”.

## Relationship to the Playwright on Codespaces VS Code extension
## Relationship to the Playwright Local Browser Server VS Code extension

This package is the core tunneling/runtime layer used by the **Playwright on Codespaces** VS Code extension (located at [vscode-extensions/playwright-on-codespaces-vscode-extension](../../vscode-extensions/playwright-on-codespaces-vscode-extension)).
This package is the core tunneling/runtime layer used by the **Playwright Local Browser Server** VS Code extension (located at [vscode-extensions/playwright-local-browser-server-vscode-extension](../../vscode-extensions/playwright-local-browser-server-vscode-extension)).

In a typical Codespaces workflow:

- Your **tests** run inside the Codespace and call `tunneledBrowserConnection()`.
- `tunneledBrowserConnection()` starts a WebSocket server (by default on port `3000`) that a browser host can attach to.
- The VS Code extension runs on the **UI side** and starts a `PlaywrightTunnel` which connects to `ws://127.0.0.1:3000`.
- In Codespaces, this works when port `3000` is forwarded to your local machine (VS Code port forwarding makes the remote port reachable as `localhost:3000`).
- `tunneledBrowserConnection()` starts a WebSocket server (by default on port `56767`) that a browser host can attach to.
- The VS Code extension runs on the **UI side** and starts a `PlaywrightTunnel` which connects to `ws://127.0.0.1:56767`.
- In Codespaces, this works when port `56767` is forwarded to your local machine (VS Code port forwarding makes the remote port reachable as `localhost:56767`).
- Once connected, the extension hosts the actual Playwright browser process locally, while your tests continue to run remotely.

The extension provides a UI wrapper around this library (start/stop commands, status bar state, and logs), while `@rushstack/playwright-browser-tunnel` provides the underlying protocol forwarding and browser lifecycle management.

### Detecting whether the VS Code extension is present

Some remote test fixtures want to detect whether the **Playwright on Codespaces** extension is installed/active (for example, to skip local-browser-only scenarios when the extension isn’t available).
Some remote test fixtures want to detect whether the **Playwright Local Browser Server** extension is installed/active (for example, to skip local-browser-only scenarios when the extension isn’t available).

The extension writes a marker file named `.playwright-codespaces-extension-installed.txt` into the remote environment’s `os.tmpdir()` using VS Code’s remote filesystem APIs.
The extension writes a marker file named `.playwright-local-browser-server-extension-installed.txt` into the remote environment’s `os.tmpdir()` using VS Code’s remote filesystem APIs.

On the remote side, `isExtensionInstalledAsync()` checks for that marker file and returns `true` if it exists:

```ts
import { isExtensionInstalledAsync } from '@rushstack/playwright-browser-tunnel';

if (!(await isExtensionInstalledAsync())) {
throw new Error('Playwright on Codespaces extension is not installed/active in this environment');
throw new Error('Playwright Local Browser Server extension is not installed/active in this environment');
}
```

Expand Down Expand Up @@ -76,7 +76,7 @@ const terminal = new Terminal(terminalProvider);

const tunnel = new PlaywrightTunnel({
mode: 'wait-for-incoming-connection',
listenPort: 3000,
listenPort: 56767,
tmpPath: path.join(os.tmpdir(), 'playwright-browser-tunnel'),
terminal,
onStatusChange: (status) => terminal.writeLine(`status: ${status}`)
Expand All @@ -97,7 +97,7 @@ Use `tunneledBrowserConnection()` in the environment where your tests run.

It starts:

- a **remote** WebSocket server (port `3000`) that the browser host connects to
- a **remote** WebSocket server (port `56767`) that the browser host connects to
- a **local** WebSocket endpoint (random port) that your Playwright client connects to

```ts
Expand Down
2 changes: 1 addition & 1 deletion apps/playwright-browser-tunnel/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',
// baseURL: 'http://localhost:56767',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface IHandshakeAck {
action: 'handshakeAck';
}

const DEFAULT_LISTEN_PORT: number = 3000;
const DEFAULT_LISTEN_PORT: number = 56767;

/**
* Disposable handle returned by {@link tunneledBrowserConnection}.
Expand Down
9 changes: 5 additions & 4 deletions apps/playwright-browser-tunnel/src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ import { tmpdir } from 'node:os';
import { FileSystem } from '@rushstack/node-core-library';

/**
* The filename used to indicate that the Playwright on Codespaces extension is installed.
* The filename used to indicate that the Playwright Local Browser Server extension is installed.
* @beta
*/
export const EXTENSION_INSTALLED_FILENAME: string = '.playwright-codespaces-extension-installed.txt';
export const EXTENSION_INSTALLED_FILENAME: string =
'.playwright-local-browser-server-extension-installed.txt';

/**
* Helper to determine if the Playwright on Codespaces extension is installed. This check's for the
* Helper to determine if the Playwright Local Browser Server extension is installed. This checks for the
* existence of a well-known file in the OS temp directory.
* @beta
*/
export async function isExtensionInstalledAsync(): Promise<boolean> {
// Read file from os.tempdir() + '/.playwright-codespaces-extension-installed'
// Read file from os.tempdir() + '/.playwright-local-browser-server-extension-installed'
const tempDir: string = tmpdir();

const extensionInstalledFilePath: string = `${tempDir}/${EXTENSION_INSTALLED_FILENAME}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/playwright-browser-tunnel",
"comment": "Update marker file names to reflect Copilot rebranding",
"type": "minor"
}
],
"packageName": "@rushstack/playwright-browser-tunnel"
}
5 changes: 5 additions & 0 deletions common/config/azure-pipelines/vscode-extension-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ parameters:
vsixPath: 'extension.vsix'
manifestPath: 'extension.signature.manifest'
projectPath: '$(Build.SourcesDirectory)/vscode-extensions/debug-certificate-manager-vscode-extension'
- key: 'playwright-local-browser-server-vscode-extension'
projectRelativeAssetsDir: dist/vsix
vsixPath: 'extension.vsix'
manifestPath: 'extension.signature.manifest'
projectPath: '$(Build.SourcesDirectory)/vscode-extensions/playwright-local-browser-server-vscode-extension'
- key: 'rush-vscode-extension'
projectRelativeAssetsDir: dist/vsix
vsixPath: 'extension.vsix'
Expand Down
2 changes: 1 addition & 1 deletion common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -1478,8 +1478,8 @@
"tags": ["vsix"]
},
{
"packageName": "playwright-on-codespaces",
"projectFolder": "vscode-extensions/playwright-on-codespaces-vscode-extension",
"packageName": "playwright-local-browser-server",
"projectFolder": "vscode-extensions/playwright-local-browser-server-vscode-extension",
"reviewCategory": "vscode-extensions",
"tags": ["vsix"]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
playwright-on-codespaces
playwright-local-browser-server

Copyright (c) Microsoft Corporation. All rights reserved.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Playwright on Codespaces VS Code Extension
# Playwright Local Browser Server VS Code Extension

Enables running Playwright tests in a remote VS Code environment (such as GitHub Codespaces) while launching and driving the actual browser process on your local machine.

This extension is a UI wrapper around the tunneling/runtime library [`@rushstack/playwright-browser-tunnel`](../../apps/playwright-browser-tunnel). It starts/stops the local browser host process and forwards Playwright’s WebSocket traffic between the remote test runner and your local browser.

## How it works

- Remote side (Codespace): your Playwright test fixture starts a WebSocket **tunnel server** on a well-known port (default `3000`) and a small local HTTP endpoint used by the Playwright client.
- Remote side (Codespace): your Playwright test fixture starts a WebSocket **tunnel server** on a well-known port (default `56767`) and a small local HTTP endpoint used by the Playwright client.
- Local side (your VS Code UI machine): this extension starts a `PlaywrightTunnel` in `poll-connection` mode and connects to the forwarded tunnel port.
- After a handshake (browser type, launch options, Playwright version), the extension installs the requested Playwright/browser as needed, launches a local `browserServer`, and begins bidirectional forwarding.

Expand Down Expand Up @@ -42,7 +42,7 @@ export const test = base.extend({

## How `extensionIsInstalled()` works with this extension

To help remote test code detect whether this extension is installed/active, the extension writes a marker file named `.playwright-codespaces-extension-installed.txt` into the remote environment’s `os.tmpdir()` when VS Code is connected to a remote workspace.
To help remote test code detect whether this extension is installed/active, the extension writes a marker file named `.playwright-local-browser-server-extension-installed.txt` into the remote environment’s `os.tmpdir()` when VS Code is connected to a remote workspace.

On the test (remote) side, you can call `extensionIsInstalled()` from `@rushstack/playwright-browser-tunnel`, which simply checks for that marker file:

Expand All @@ -51,7 +51,7 @@ import { extensionIsInstalled } from '@rushstack/playwright-browser-tunnel';

if (!(await extensionIsInstalled())) {
throw new Error(
'Playwright on Codespaces VS Code extension not detected. Install/enable it and ensure VS Code is connected to the remote workspace.'
'Playwright Local Browser Server VS Code extension not detected. Install/enable it and ensure VS Code is connected to the remote workspace.'
);
}
```
Expand Down Expand Up @@ -125,18 +125,20 @@ sequenceDiagram

This extension contributes the following commands:

- **Playwright: Start Playwright Browser Tunnel** (`playwright-tunnel.start`)
- **Playwright: Stop Playwright Browser Tunnel** (`playwright-tunnel.stop`)
- **Playwright on Codespaces: Show Log** (`playwright-tunnel.showLog`)
- **Playwright on Codespaces: Show Settings** (`playwright-tunnel.showSettings`)
- **Playwright on Codespaces: Show Tunnel Menu** (`playwright-tunnel.showMenu`) — status bar menu
- **Playwright: Start Playwright Browser Tunnel** (`playwright-local-browser-server.start`)
- **Playwright: Stop Playwright Browser Tunnel** (`playwright-local-browser-server.stop`)
- **Playwright Local Browser Server: Manage Launch Options Allowlist** (`playwright-local-browser-server.manageAllowlist`)
- **Playwright Local Browser Server: Show Log** (`playwright-local-browser-server.showLog`)
- **Playwright Local Browser Server: Show Settings** (`playwright-local-browser-server.showSettings`)
- **Playwright Local Browser Server: Show Tunnel Menu** (`playwright-local-browser-server.showMenu`) — status bar menu

## Settings

- `playwright-tunnel.autoStart` (default: `true`) — automatically starts the tunnel when the extension activates.
- `playwright-tunnel.tunnelPort` (default: `3000`) — port used by the remote tunnel server.
- `playwright-local-browser-server.autoStart` (default: `false`) — automatically starts the tunnel when the extension activates.
- `playwright-local-browser-server.promptBeforeLaunch` (default: `true`) — show a confirmation prompt before launching the browser server with the requested launch options. This helps protect against potentially malicious launch options from compromised environments.
- `playwright-local-browser-server.tunnelPort` (default: `56767`) — port used by the remote tunnel server.

## Notes

- The extension currently connects to `ws://127.0.0.1:3000` on the local machine. In Codespaces, make sure the remote port is forwarded so it is reachable as `localhost` from your VS Code UI environment.
- The extension currently connects to `ws://127.0.0.1:56767` on the local machine. In Codespaces, make sure the remote port is forwarded so it is reachable as `localhost` from your VS Code UI environment.
- For the underlying API and examples, see [`@rushstack/playwright-browser-tunnel`](../../apps/playwright-browser-tunnel).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading