Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(devtools): kill-all (#39410)

Simon Knott135d04857796
diff --git a/packages/playwright/src/cli/client/program.ts b/packages/playwright/src/cli/client/program.ts
index a86d82b3b0..c206d97818 100644
--- a/packages/playwright/src/cli/client/program.ts
+++ b/packages/playwright/src/cli/client/program.ts
@@ -366,7 +366,7 @@ async function killAllDaemons(): Promise<void> {
const result = execSync(
`powershell -NoProfile -NonInteractive -Command `
+ `"Get-CimInstance Win32_Process `
- + `| Where-Object { $_.CommandLine -like '*-server*' -and $_.CommandLine -like '*--daemon-session*' } `
+ + `| Where-Object { ($_.CommandLine -like '*-server*' -and $_.CommandLine -like '*--daemon-session*') -or $_.CommandLine -like '*devtoolsApp.js*' } `
+ `| ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue; $_.ProcessId }"`,
{ encoding: 'utf-8' }
);
@@ -380,7 +380,7 @@ async function killAllDaemons(): Promise<void> {
const result = execSync('ps aux', { encoding: 'utf-8' });
const lines = result.split('\n');
for (const line of lines) {
- if ((line.includes('-server')) && line.includes('--daemon-session')) {
+ if ((line.includes('-server') && line.includes('--daemon-session')) || line.includes('devtoolsApp.js')) {
const parts = line.trim().split(/\s+/);
const pid = parts[1];
if (pid && /^\d+$/.test(pid)) {
diff --git a/tests/mcp/cli-show.spec.ts b/tests/mcp/cli-show.spec.ts
index 147401ca3c..b401c10374 100644
--- a/tests/mcp/cli-show.spec.ts
+++ b/tests/mcp/cli-show.spec.ts
@@ -21,3 +21,10 @@ test('running show twice gets same PID', async ({ cli }) => {
const two = await cli('show', { env: { PWTEST_UNDER_TEST: '1' } });
expect(one.output).toEqual(two.output);
});
+
+test('kill-all closes devtools', async ({ cli }) => {
+ const one = await cli('show', { env: { PWTEST_UNDER_TEST: '1' } });
+ await cli('kill-all');
+ const two = await cli('show', { env: { PWTEST_UNDER_TEST: '1' } });
+ expect(one.output).not.toEqual(two.output);
+});