Skip to content

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

fix(test): use separate Playwright instance for inspector tests (#40151)

Yury Semikhatskye4664bf3f6c5
diff --git a/packages/playwright-core/src/inprocess.ts b/packages/playwright-core/src/inprocess.ts
index 14d9572edc..fba4fb5ad7 100644
--- a/packages/playwright-core/src/inprocess.ts
+++ b/packages/playwright-core/src/inprocess.ts
@@ -24,7 +24,7 @@ import { packageRoot } from './package';
import type { Playwright as PlaywrightAPI } from './client/playwright';
import type { Language } from '@isomorphic/locatorGenerators';
-function createInProcessPlaywright(): PlaywrightAPI {
+export function createInProcessPlaywright(): PlaywrightAPI {
const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });
const clientConnection = new Connection(nodePlatform(packageRoot));
clientConnection.useRawBuffers();
diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.ts
index 199207b14d..81a088623b 100644
--- a/tests/library/inspector/inspectorTest.ts
+++ b/tests/library/inspector/inspectorTest.ts
@@ -47,7 +47,9 @@ const codegenLang2Id: Map<string, string> = new Map([
const codegenLangId2lang = new Map([...codegenLang2Id.entries()].map(([lang, langId]) => [langId, lang]));
import { inprocess } from '../../../packages/playwright-core/lib/coreBundle';
-const playwrightToAutomateInspector = inprocess.playwright;
+// Use a separate Playwright instance for automating the inspector so that
+// contexts created here do not get tracked by the test runner's tracing.
+const playwrightToAutomateInspector = inprocess.createInProcessPlaywright();
export const test = contextTest.extend<CLITestArgs>({
recorderPageGetter: async ({ context, toImpl, mode, headless }, run, testInfo) => {