Skip to content

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

chore: turn PWDEBUG back to opt-in (#37028)

Simon Knott0e4ad3299208
diff --git a/packages/playwright-core/src/server/utils/debug.ts b/packages/playwright-core/src/server/utils/debug.ts
index 4523b2f786..680113d904 100644
--- a/packages/playwright-core/src/server/utils/debug.ts
+++ b/packages/playwright-core/src/server/utils/debug.ts
@@ -23,7 +23,7 @@ export function debugMode() {
return 'console';
if (_debugMode === '0' || _debugMode === 'false')
return '';
- return _debugMode ? 'inspector' : 'console';
+ return _debugMode ? 'inspector' : '';
}
const _isUnderTest = getAsBooleanFromENV('PWTEST_UNDER_TEST');
diff --git a/tests/library/inspector/pause.spec.ts b/tests/library/inspector/pause.spec.ts
index 550fd5fa8d..1d202e5b88 100644
--- a/tests/library/inspector/pause.spec.ts
+++ b/tests/library/inspector/pause.spec.ts
@@ -88,7 +88,7 @@ it.describe('pause', () => {
// @ts-ignore
await page.pause({ __testHookKeepTestTimeout: true });
})();
- await page.waitForFunction(() => (window as any).playwright?.resume() !== false);
+ await page.waitForFunction(() => (window as any).playwright && (window as any).playwright.resume() !== false);
await scriptPromise;
});
diff --git a/tests/playwright-test/playwright.spec.ts b/tests/playwright-test/playwright.spec.ts
index c8313acaf1..c00cb3587a 100644
--- a/tests/playwright-test/playwright.spec.ts
+++ b/tests/playwright-test/playwright.spec.ts
@@ -896,15 +896,14 @@ test('page.pause() should disable test timeout', async ({ runInlineTest }) => {
expect(result.output).toContain('success!');
});
-test('window.playwright should be exposed by default', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/36772' } }, async ({ runInlineTest }) => {
+test('window.playwright should be undefined by default', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('test', async ({ page }) => {
await page.setContent('<body></body>');
- const bodyTag = await page.evaluate(() => window.playwright.$('body').tagName);
- expect(bodyTag).toBe('BODY');
+ expect(await page.evaluate(() => window.playwright)).toBeUndefined();
});
`,
}, {}, {});
@@ -912,7 +911,7 @@ test('window.playwright should be exposed by default', { annotation: { type: 'is
expect(result.passed).toBe(1);
});
-test('window.playwright should not override existing property', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/36772' } }, async ({ runInlineTest }) => {
+test('window.playwright should not override existing property', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
import { test, expect } from '@playwright/test';
@@ -922,22 +921,22 @@ test('window.playwright should not override existing property', { annotation: {
expect(await page.evaluate(() => window.playwright)).toBe('foo');
});
`,
- }, {}, {});
+ }, {}, { PWDEBUG: 'console' });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});
-test('PWDEBUG=0 should opt-out from exposing window.playwright', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/36772' } }, async ({ runInlineTest }) => {
+test('PWDEBUG=console should opt-in to exposing window.playwright', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('test', async ({ page }) => {
await page.setContent('<body></body>');
- expect(await page.evaluate(() => window.playwright)).toBeUndefined();
+ expect(await page.evaluate(() => window.playwright)).toBeDefined();
});
`,
- }, {}, { PWDEBUG: '0' });
+ }, {}, { PWDEBUG: 'console' });
expect(result.exitCode).toBe(0);
expect(result.passed).toBe(1);
});