From 42876a0528e6ddefb177062709d952fb6feedd16 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 25 Jan 2022 09:40:24 -0700 Subject: [PATCH] fix: support PWDEBUG=0 to disable debug (#11611) Fixes #11606 --- packages/playwright-core/src/utils/utils.ts | 2 ++ packages/playwright-test/src/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/src/utils/utils.ts b/packages/playwright-core/src/utils/utils.ts index e977c26f10..249f110fdf 100644 --- a/packages/playwright-core/src/utils/utils.ts +++ b/packages/playwright-core/src/utils/utils.ts @@ -325,6 +325,8 @@ const debugEnv = getFromENV('PWDEBUG') || ''; export function debugMode() { if (debugEnv === 'console') return 'console'; + if (debugEnv === '0' || debugEnv === 'false') + return ''; return debugEnv ? 'inspector' : ''; } diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.ts index 3b10e8f8ee..3374aa3d72 100644 --- a/packages/playwright-test/src/index.ts +++ b/packages/playwright-test/src/index.ts @@ -19,7 +19,7 @@ import * as path from 'path'; import type { LaunchOptions, BrowserContextOptions, Page, BrowserContext, BrowserType, Video, Browser, APIRequestContext } from 'playwright-core'; import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestInfo } from '../types/test'; import { rootTestType } from './testType'; -import { createGuid, removeFolders } from 'playwright-core/lib/utils/utils'; +import { createGuid, removeFolders, debugMode } from 'playwright-core/lib/utils/utils'; import { GridClient } from 'playwright-core/lib/grid/gridClient'; import { prependToTestError } from './util'; export { expect } from './expect'; @@ -190,7 +190,7 @@ export const test = _baseTest.extend({ _setupContextOptionsAndArtifacts: [async ({ playwright, _snapshotSuffix, _combinedContextOptions, _artifactsDir, trace, screenshot, actionTimeout, navigationTimeout }, use, testInfo) => { testInfo.snapshotSuffix = _snapshotSuffix; - if (process.env.PWDEBUG) + if (debugMode()) testInfo.setTimeout(0); let traceMode = typeof trace === 'string' ? trace : trace.mode;