From 29a84b2df831e7829655c8c86de84fec806c796a Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Thu, 27 Jan 2022 14:32:23 -0800 Subject: [PATCH] chore: allow pre-processing scripts (#11702) --- packages/playwright-test/src/index.ts | 6 ++++-- packages/playwright-test/src/matchers/toMatchText.ts | 2 -- packages/playwright-test/src/transform.ts | 5 ++++- tests/config/default.playwright.config.ts | 2 +- tests/config/testMode.ts | 4 +++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.ts index d8b59cce66..77d4964309 100644 --- a/packages/playwright-test/src/index.ts +++ b/packages/playwright-test/src/index.ts @@ -58,8 +58,10 @@ export const test = _baseTest.extend({ const gridClient = await GridClient.connect(process.env.PW_GRID); await use(gridClient.playwright() as any); gridClient.close(); - } else if (process.env.PW_OUT_OF_PROCESS) { - const impl = await outOfProcess.start(); + } else if (process.env.PW_OUT_OF_PROCESS_DRIVER) { + const impl = await outOfProcess.start({ + NODE_OPTIONS: undefined // Hide driver process while debugging. + }); await use(impl.playwright as any); await impl.stop(); } else { diff --git a/packages/playwright-test/src/matchers/toMatchText.ts b/packages/playwright-test/src/matchers/toMatchText.ts index fd3455c664..42cdb09730 100644 --- a/packages/playwright-test/src/matchers/toMatchText.ts +++ b/packages/playwright-test/src/matchers/toMatchText.ts @@ -123,8 +123,6 @@ Call log: export function currentExpectTimeout(options: { timeout?: number }) { const testInfo = currentTestInfo(); - if (testInfo && !testInfo.timeout) - return 0; if (options.timeout !== undefined) return options.timeout; let defaultExpectTimeout = testInfo?.project.expect?.timeout; diff --git a/packages/playwright-test/src/transform.ts b/packages/playwright-test/src/transform.ts index 7a498352a5..3b311d08e8 100644 --- a/packages/playwright-test/src/transform.ts +++ b/packages/playwright-test/src/transform.ts @@ -58,6 +58,7 @@ sourceMapSupport.install({ function calculateCachePath(tsconfigData: ParsedTsConfigData | undefined, content: string, filePath: string): string { const hash = crypto.createHash('sha1') .update(tsconfigData?.hash || '') + .update(process.env.PW_TEST_SOURCE_TRANSFORM || '') .update(process.env.PW_EXPERIMENTAL_TS_ESM ? 'esm' : 'no_esm') .update(content) .update(filePath) @@ -134,7 +135,6 @@ export function transformHook(code: string, filename: string, isModule = false): // Silence the annoying warning. process.env.BROWSERSLIST_IGNORE_OLD_DATA = 'true'; const babel: typeof import('@babel/core') = require('@babel/core'); - const plugins = [ [require.resolve('@babel/plugin-proposal-class-properties')], [require.resolve('@babel/plugin-proposal-numeric-separator')], @@ -166,6 +166,9 @@ export function transformHook(code: string, filename: string, isModule = false): plugins.push([require.resolve('@babel/plugin-proposal-dynamic-import')]); } + if (process.env.PW_TEST_SOURCE_TRANSFORM) + plugins.push([process.env.PW_TEST_SOURCE_TRANSFORM]); + const result = babel.transformFileSync(filename, { babelrc: false, configFile: false, diff --git a/tests/config/default.playwright.config.ts b/tests/config/default.playwright.config.ts index 4a9c5c967d..6d10a11326 100644 --- a/tests/config/default.playwright.config.ts +++ b/tests/config/default.playwright.config.ts @@ -30,7 +30,7 @@ const getExecutablePath = (browserName: BrowserName) => { return process.env.WKPATH; }; -const mode = process.env.PW_OUT_OF_PROCESS ? +const mode = process.env.PW_OUT_OF_PROCESS_DRIVER ? 'driver' : (process.env.PWTEST_MODE || 'default') as ('default' | 'driver' | 'service'); const headed = !!process.env.HEADFUL; diff --git a/tests/config/testMode.ts b/tests/config/testMode.ts index 200ef7f9be..6f470cbc6a 100644 --- a/tests/config/testMode.ts +++ b/tests/config/testMode.ts @@ -29,7 +29,9 @@ export class DriverTestMode implements TestMode { private _impl: { playwright: Playwright; stop: () => Promise; }; async setup() { - this._impl = await start(); + this._impl = await start({ + NODE_OPTIONS: undefined // Hide driver process while debugging. + }); return this._impl.playwright; }