diff --git a/src/PlaywrightEnvironment.ts b/src/PlaywrightEnvironment.ts index edd4962c..98d8c75f 100644 --- a/src/PlaywrightEnvironment.ts +++ b/src/PlaywrightEnvironment.ts @@ -100,6 +100,7 @@ export const getPlaywrightEnv = (basicEnv = 'node'): unknown => { exitOnPageError, selectors, launchType, + debugOptions, } = this._jestPlaywrightConfig if (wsEndpoint && !connectOptions?.wsEndpoint) { this._jestPlaywrightConfig.connectOptions = { @@ -184,18 +185,24 @@ export const getPlaywrightEnv = (basicEnv = 'node'): unknown => { let resultBrowserConfig: JestPlaywrightConfig let resultContextOptions: BrowserContextOptions | undefined if (isDebug) { - resultBrowserConfig = config - resultContextOptions = config.contextOptions + resultBrowserConfig = debugOptions + ? deepMerge(config, debugOptions) + : config + resultContextOptions = + debugOptions && debugOptions.contextOptions + ? deepMerge( + config.contextOptions!, + debugOptions.contextOptions!, + ) + : config.contextOptions } else { - resultBrowserConfig = deepMerge(this._jestPlaywrightConfig, { - ...config, - launchType: LAUNCH, - }) + resultBrowserConfig = deepMerge(this._jestPlaywrightConfig, config) resultContextOptions = { ...this._jestPlaywrightConfig.contextOptions, ...config.contextOptions, } } + resultBrowserConfig.launchType = LAUNCH const browser = await getBrowserPerProcess( playwrightInstance, browserType, diff --git a/types/global.d.ts b/types/global.d.ts index 1e12cc33..31e1d458 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -156,6 +156,7 @@ type Options = T & Partial> export type ConnectOptions = Parameters[0] export interface JestPlaywrightConfig { + debugOptions?: JestPlaywrightConfig launchType?: LaunchType launchOptions?: Options connectOptions?: Options